Skip to content

Commit 72031b0

Browse files
Use -0.0 as the neutral additive float
-0.0 + 0.0 is 0.0 -0.0 + -0.0 is -0.0 Thus, the float additive-zero is actually -0.0, not its positive cousin. This change aligns with a recent change to the impl of Sum for floats, in rust-lang/rust@4908188
1 parent 5fb43ca commit 72031b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/core_simd/src/simd/num/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ macro_rules! impl_trait {
419419
self.as_array().iter().sum()
420420
} else {
421421
// Safety: `self` is a float vector
422-
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, 0.) }
422+
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, -0.) }
423423
}
424424
}
425425

0 commit comments

Comments
 (0)