Skip to content

Commit 609effa

Browse files
committed
Add test cases for subnormal inputs to Float::integer_decode
1 parent 300a7f9 commit 609effa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/float.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,7 @@ mod tests {
24562456
for sign in [1, -1] {
24572457
let sign_f = sign as f32;
24582458
test_integer_decode(sign_f * 0.0__f32, (0x000000, -150, sign));
2459+
test_integer_decode(sign_f * 1.0e-40_f32, (0x8116c2, -150, sign)); // subnormal (between 0 and MIN_POSITIVE)
24592460
test_integer_decode(sign_f * f32::MIN_POSITIVE, (0x800000, -149, sign));
24602461
test_integer_decode(sign_f * 0.25_f32, (0x800000, -25, sign));
24612462
test_integer_decode(sign_f * 0.5__f32, (0x800000, -24, sign));
@@ -2478,6 +2479,7 @@ mod tests {
24782479
for sign in [1, -1] {
24792480
let sign_f = sign as f64;
24802481
test_integer_decode(sign_f * 0.0__f64, (0x00000000000000, -1075, sign));
2482+
test_integer_decode(sign_f * 1.0e-308_f64, (0x1730d67819e8d2, -1075, sign)); // subnormal (between 0 and MIN_POSITIVE)
24812483
test_integer_decode(sign_f * f64::MIN_POSITIVE, (0x10000000000000, -1074, sign));
24822484
test_integer_decode(sign_f * 0.25_f64, (0x10000000000000, -54, sign));
24832485
test_integer_decode(sign_f * 0.5__f64, (0x10000000000000, -53, sign));

0 commit comments

Comments
 (0)