Skip to content

Commit 8374538

Browse files
committed
This updates the exponent calculations done in the nextafter functions related
to detecting underflow/overflow. The functions now match the behavior of the MUSL implementations these were based on. Fixes rust-lang#286
1 parent 721a5ed commit 8374538

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/math/nextafter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn nextafter(x: f64, y: f64) -> f64 {
2323
ux_i += 1;
2424
}
2525

26-
let e = ux_i.wrapping_shr(52 & 0x7ff);
26+
let e = ux_i >> 52 & 0x7ff;
2727
// raise overflow if ux.f is infinite and x is finite
2828
if e == 0x7ff {
2929
force_eval!(x + x);

src/math/nextafterf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn nextafterf(x: f32, y: f32) -> f32 {
2323
ux_i += 1;
2424
}
2525

26-
let e = ux_i.wrapping_shr(0x7f80_0000_u32);
26+
let e = ux_i & 0x7f80_0000_u32;
2727
// raise overflow if ux_f is infinite and x is finite
2828
if e == 0x7f80_0000_u32 {
2929
force_eval!(x + x);

0 commit comments

Comments
 (0)