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 #286
This commit is contained in:
@@ -23,7 +23,7 @@ pub fn nextafter(x: f64, y: f64) -> f64 {
|
|||||||
ux_i += 1;
|
ux_i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let e = ux_i.wrapping_shr(52 & 0x7ff);
|
let e = ux_i >> 52 & 0x7ff;
|
||||||
// raise overflow if ux.f is infinite and x is finite
|
// raise overflow if ux.f is infinite and x is finite
|
||||||
if e == 0x7ff {
|
if e == 0x7ff {
|
||||||
force_eval!(x + x);
|
force_eval!(x + x);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub fn nextafterf(x: f32, y: f32) -> f32 {
|
|||||||
ux_i += 1;
|
ux_i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let e = ux_i.wrapping_shr(0x7f80_0000_u32);
|
let e = ux_i & 0x7f80_0000_u32;
|
||||||
// raise overflow if ux_f is infinite and x is finite
|
// raise overflow if ux_f is infinite and x is finite
|
||||||
if e == 0x7f80_0000_u32 {
|
if e == 0x7f80_0000_u32 {
|
||||||
force_eval!(x + x);
|
force_eval!(x + x);
|
||||||
|
|||||||
Reference in New Issue
Block a user