Skip to content

Commit 3881e4e

Browse files
committed
Fix for num-bigint bits() -> u64
1 parent 6725448 commit 3881e4e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,19 +1464,19 @@ impl<T: Clone + Integer + ToPrimitive + ToBigInt> ToPrimitive for Ratio<T> {
14641464
}
14651465

14661466
trait Bits {
1467-
fn bits(&self) -> usize;
1467+
fn bits(&self) -> u64;
14681468
}
14691469

14701470
#[cfg(feature = "bigint")]
14711471
impl Bits for BigInt {
1472-
fn bits(&self) -> usize {
1472+
fn bits(&self) -> u64 {
14731473
self.bits()
14741474
}
14751475
}
14761476

14771477
impl Bits for i128 {
1478-
fn bits(&self) -> usize {
1479-
(128 - self.wrapping_abs().leading_zeros()) as usize
1478+
fn bits(&self) -> u64 {
1479+
(128 - self.wrapping_abs().leading_zeros()).into()
14801480
}
14811481
}
14821482

@@ -1526,11 +1526,11 @@ fn ratio_to_f64<T: Bits + Clone + Integer + Signed + ShlAssign<usize> + ToPrimit
15261526

15271527
// Filter out overflows and underflows. After this step, the signed difference fits in an
15281528
// isize.
1529-
if is_diff_positive && absolute_diff > core::f64::MAX_EXP as usize {
1529+
if is_diff_positive && absolute_diff > core::f64::MAX_EXP as u64 {
15301530
return core::f64::INFINITY * flo_sign;
15311531
}
15321532
if !is_diff_positive
1533-
&& absolute_diff > -core::f64::MIN_EXP as usize + core::f64::MANTISSA_DIGITS as usize + 1
1533+
&& absolute_diff > -core::f64::MIN_EXP as u64 + core::f64::MANTISSA_DIGITS as u64 + 1
15341534
{
15351535
return 0.0 * flo_sign;
15361536
}

0 commit comments

Comments
 (0)