File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ mod int_to_float {
13
13
let a = ( i << n) >> 8 ; // Significant bits, with bit 24 still in tact.
14
14
let b = ( i << n) << 24 ; // Insignificant bits, only relevant for rounding.
15
15
let m = a + ( ( b - ( b >> 31 & !a) ) >> 31 ) ; // Add one when we need to round up. Break ties to even.
16
- let e = 157 - n as u32 ; // Exponent plus 127, minus one.
16
+ let e = 157 - n; // Exponent plus 127, minus one.
17
17
( e << 23 ) + m // + not |, so the mantissa can overflow into the exponent.
18
18
}
19
19
@@ -42,8 +42,8 @@ mod int_to_float {
42
42
return 0 ;
43
43
}
44
44
let n = i. leading_zeros ( ) ;
45
- let a = ( ( i << n) >> 11 ) as u64 ; // Significant bits, with bit 53 still in tact.
46
- let b = ( ( i << n) << 53 ) as u64 ; // Insignificant bits, only relevant for rounding.
45
+ let a = ( i << n) >> 11 ; // Significant bits, with bit 53 still in tact.
46
+ let b = ( i << n) << 53 ; // Insignificant bits, only relevant for rounding.
47
47
let m = a + ( ( b - ( b >> 63 & !a) ) >> 63 ) ; // Add one when we need to round up. Break ties to even.
48
48
let e = 1085 - n as u64 ; // Exponent plus 1023, minus one.
49
49
( e << 52 ) + m // + not |, so the mantissa can overflow into the exponent.
Original file line number Diff line number Diff line change @@ -135,11 +135,11 @@ where
135
135
136
136
let mut correction: u32 =
137
137
negate_u32 ( ( ( reciprocal as u64 ) . wrapping_mul ( q31b as u64 ) >> 32 ) as u32 ) ;
138
- reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) as u64 >> 31 ) as u32 ;
138
+ reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) >> 31 ) as u32 ;
139
139
correction = negate_u32 ( ( ( reciprocal as u64 ) . wrapping_mul ( q31b as u64 ) >> 32 ) as u32 ) ;
140
- reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) as u64 >> 31 ) as u32 ;
140
+ reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) >> 31 ) as u32 ;
141
141
correction = negate_u32 ( ( ( reciprocal as u64 ) . wrapping_mul ( q31b as u64 ) >> 32 ) as u32 ) ;
142
- reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) as u64 >> 31 ) as u32 ;
142
+ reciprocal = ( ( reciprocal as u64 ) . wrapping_mul ( correction as u64 ) >> 31 ) as u32 ;
143
143
144
144
// Exhaustive testing shows that the error in reciprocal after three steps
145
145
// is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our
You can’t perform that action at this time.
0 commit comments