Skip to content

Commit 193cd14

Browse files
committed
Enable special handling of zero
1 parent a7b82ad commit 193cd14

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

crates/core_simd/tests/ops_macros.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,20 +501,24 @@ macro_rules! impl_float_tests {
501501

502502
fn max_lane<const LANES: usize>() {
503503
test_helpers::test_1(&|x| {
504-
test_helpers::prop_assert_biteq! (
505-
Vector::<LANES>::from_array(x).max_lane(),
506-
x.iter().copied().fold(Scalar::NAN, Scalar::max),
507-
);
504+
let vmax = Vector::<LANES>::from_array(x).max_lane();
505+
let smax = x.iter().copied().fold(Scalar::NAN, Scalar::max);
506+
// 0 and -0 are treated the same
507+
if !(x.contains(&0.) && x.contains(&-0.) && vmax.abs() == 0. && smax.abs() == 0.) {
508+
test_helpers::prop_assert_biteq!(vmax, smax);
509+
}
508510
Ok(())
509511
});
510512
}
511513

512514
fn min_lane<const LANES: usize>() {
513515
test_helpers::test_1(&|x| {
514-
test_helpers::prop_assert_biteq! (
515-
Vector::<LANES>::from_array(x).min_lane(),
516-
x.iter().copied().fold(Scalar::NAN, Scalar::min),
517-
);
516+
let vmax = Vector::<LANES>::from_array(x).min_lane();
517+
let smax = x.iter().copied().fold(Scalar::NAN, Scalar::min);
518+
// 0 and -0 are treated the same
519+
if !(x.contains(&0.) && x.contains(&-0.) && vmax.abs() == 0. && smax.abs() == 0.) {
520+
test_helpers::prop_assert_biteq!(vmax, smax);
521+
}
518522
Ok(())
519523
});
520524
}

0 commit comments

Comments
 (0)