Skip to content

Commit 0a0a8e5

Browse files
committed
Fix bug causing subnormal test case to fail
1 parent 5477176 commit 0a0a8e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/float.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,15 +2066,16 @@ macro_rules! integer_decode {
20662066

20672067
let sign: i8 = if bits >> $size - 1 == 0 { 1 } else { -1 };
20682068

2069-
let mantissa = if f == 0 as $F {
2069+
let mut exponent: i16 = (bits >> $fraction_size & $postshift_exponent_bits_mask) as i16;
2070+
2071+
let mantissa = if exponent == 0 {
20702072
// Zeros and subnormals
20712073
(bits & $fraction_bits_mask) << 1
20722074
} else {
20732075
// Normals, infinities, and NaN
20742076
(bits & $fraction_bits_mask) | $exponent_least_signifigant_bit_mask
20752077
};
20762078

2077-
let mut exponent: i16 = (bits >> $fraction_size & $postshift_exponent_bits_mask) as i16;
20782079
exponent -= $exponent_bias + $fraction_size;
20792080

20802081
(mantissa as u64, exponent, sign)

0 commit comments

Comments
 (0)