Skip to content

Commit

Permalink
nextafter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jan 24, 2024
1 parent 6412fc2 commit f9f499f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,15 @@ pub fn nextafter(x: f64, y: f64) -> f64 {
let mut cxi = x.to_bits() as i64;
let c = (cxi < 0) == (y < x);
if c {
cxi = -(cxi ^ (1 << 63));
cxi = -(cxi ^ i64::MIN);
}

if x != y {
cxi -= 1;
}

if c {
cxi = -(((cxi as u64) ^ (1u64 << 63)) as i64);
cxi = -(cxi ^ i64::MIN);
}

let cxf = f64::from_bits(cxi as u64);
Expand Down
4 changes: 2 additions & 2 deletions src/f64x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ where
let mut xi2 = x.to_bits().cast::<i64>();
let c = x.is_sign_negative() ^ y.simd_ge(x);

let mut t = (xi2 ^ I64x::splat(0x_7fff_ffff_ffff_ffff_u64 as _)) + I64x::splat(1);
let mut t = (xi2 ^ I64x::splat(i64::MAX)) + I64x::splat(1);
t += swap_upper_lower(
I64x::splat(1)
& t.simd_eq(I64x::splat(0x_ffff_ffff_0000_0000_u64 as _))
Expand Down Expand Up @@ -943,7 +943,7 @@ where
.to_bits()
.cast();

let mut t = (xi2 ^ I64x::splat(0x_7fff_ffff_ffff_ffff_u64 as _)) + I64x::splat(1);
let mut t = (xi2 ^ I64x::splat(i64::MAX)) + I64x::splat(1);
t += swap_upper_lower(
I64x::splat(1)
& t.simd_eq(I64x::splat(0x_ffff_ffff_0000_0000_u64 as _))
Expand Down

0 comments on commit f9f499f

Please sign in to comment.