Skip to content

Commit 9094404

Browse files
committed
Cleanup normalize()
1 parent c150b87 commit 9094404

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/float/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl Float for f32 {
3838
unsafe { mem::transmute(a) }
3939
}
4040
fn normalize(significand: Self::Int) -> (Self::Int, Self::Int) {
41-
let shift = Self::Int::leading_zeros(significand)
42-
.wrapping_sub(Self::Int::leading_zeros(1 << Self::significand_bits()));
41+
let shift = significand.leading_zeros()
42+
.wrapping_sub((1u32 << Self::significand_bits()).leading_zeros());
4343
(1u32.wrapping_sub(shift as Self::Int), significand << shift as Self::Int)
4444
}
4545
}
@@ -58,8 +58,8 @@ impl Float for f64 {
5858
unsafe { mem::transmute(a) }
5959
}
6060
fn normalize(significand: Self::Int) -> (Self::Int, Self::Int) {
61-
let shift = Self::Int::leading_zeros(significand)
62-
.wrapping_sub(Self::Int::leading_zeros(1 << Self::significand_bits()));
61+
let shift = significand.leading_zeros()
62+
.wrapping_sub((1u64 << Self::significand_bits()).leading_zeros());
6363
(1u64.wrapping_sub(shift as Self::Int), significand << shift as Self::Int)
6464
}
6565
}

0 commit comments

Comments
 (0)