Skip to content

Commit 51ca17a

Browse files
committed
Fix normal and subnormal classification
1 parent 77a1394 commit 51ca17a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

crates/core_simd/src/vector/float.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,14 @@ macro_rules! impl_float_vector {
7979
/// Returns true for each lane if its value is subnormal.
8080
#[inline]
8181
pub fn is_subnormal(self) -> crate::$mask_ty<LANES> {
82-
let exponent_mask = crate::$bits_ty::splat(!0 << <$type>::MANTISSA_DIGITS);
83-
self.abs().lanes_ne(Self::splat(0.0)) & (self.to_bits() & exponent_mask).lanes_eq(crate::$bits_ty::splat(0))
82+
self.abs().lanes_ne(Self::splat(0.0)) & (self.to_bits() & Self::splat(<$type>::INFINITY).to_bits()).lanes_eq(crate::$bits_ty::splat(0))
8483
}
8584

8685
/// Returns true for each lane if its value is neither neither zero, infinite,
8786
/// subnormal, or `NaN`.
8887
#[inline]
8988
pub fn is_normal(self) -> crate::$mask_ty<LANES> {
90-
!(self.abs().lanes_eq(Self::splat(0.0)) | self.is_nan() | self.is_subnormal())
89+
!(self.abs().lanes_eq(Self::splat(0.0)) | self.is_nan() | self.is_subnormal() | self.is_infinite())
9190
}
9291
}
9392
};

0 commit comments

Comments
 (0)