bigint: reapply #176

This commit is contained in:
Josh Stone 2016-03-25 17:02:31 -07:00
parent aebbc4fd37
commit 03884fdbcc
1 changed files with 5 additions and 0 deletions

View File

@ -2884,6 +2884,11 @@ impl BigInt {
str::from_utf8(buf).ok().and_then(|s| BigInt::from_str_radix(s, radix).ok()) str::from_utf8(buf).ok().and_then(|s| BigInt::from_str_radix(s, radix).ok())
} }
/// Determines the fewest bits necessary to express the `BigInt`,
/// not including the sign.
pub fn bits(&self) -> usize {
self.data.bits()
}
/// Converts this `BigInt` into a `BigUint`, if it's not negative. /// Converts this `BigInt` into a `BigUint`, if it's not negative.
#[inline] #[inline]