Skip to content

Commit c3b277a

Browse files
committed
Add comments to mantissa calculation
1 parent 6309a53 commit c3b277a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/float.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,8 +2055,10 @@ fn integer_decode_f32(f: f32) -> (u64, i16, i8) {
20552055
let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 };
20562056
let mut exponent: i16 = ((bits >> 23) & 0xff) as i16;
20572057
let mantissa = if exponent == 0 {
2058+
// Zeros and subnormals
20582059
(bits & 0x7fffff) << 1
20592060
} else {
2061+
// Normals, infinities, and NaN
20602062
(bits & 0x7fffff) | 0x800000
20612063
};
20622064
// Exponent bias + mantissa shift
@@ -2069,8 +2071,10 @@ fn integer_decode_f64(f: f64) -> (u64, i16, i8) {
20692071
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
20702072
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
20712073
let mantissa = if exponent == 0 {
2074+
// Zeros and subnormals
20722075
(bits & 0xfffffffffffff) << 1
20732076
} else {
2077+
// Normals, infinities, and NaN
20742078
(bits & 0xfffffffffffff) | 0x10000000000000
20752079
};
20762080
// Exponent bias + mantissa shift

0 commit comments

Comments
 (0)