Skip to content

Commit

Permalink
Use -0.0 as the neutral additive float
Browse files Browse the repository at this point in the history
-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 and
accordingly we also have to use the latest toolchain for our tests now.
  • Loading branch information
workingjubilee committed Sep 12, 2024
1 parent 5fb43ca commit 00c3b6d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/core_simd/src/simd/num/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ macro_rules! impl_trait {
self.as_array().iter().sum()
} else {
// Safety: `self` is a float vector
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, 0.) }
unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, -0.) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-06-13"
channel = "nightly-2024-09-11"
components = ["rustfmt", "clippy", "miri", "rust-src"]

0 comments on commit 00c3b6d

Please sign in to comment.