From f9f499f95be2456653be6c59849cbc7e1cf9ecac Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Wed, 24 Jan 2024 20:01:34 +0300 Subject: [PATCH] nextafter fix --- src/f64.rs | 4 ++-- src/f64x.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/f64.rs b/src/f64.rs index e66456b..20b6cd7 100644 --- a/src/f64.rs +++ b/src/f64.rs @@ -873,7 +873,7 @@ 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 { @@ -881,7 +881,7 @@ pub fn nextafter(x: f64, y: f64) -> f64 { } if c { - cxi = -(((cxi as u64) ^ (1u64 << 63)) as i64); + cxi = -(cxi ^ i64::MIN); } let cxf = f64::from_bits(cxi as u64); diff --git a/src/f64x.rs b/src/f64x.rs index 9836740..b7f46de 100644 --- a/src/f64x.rs +++ b/src/f64x.rs @@ -915,7 +915,7 @@ where let mut xi2 = x.to_bits().cast::(); 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 _)) @@ -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 _))