We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e8b6bca commit 91134e6Copy full SHA for 91134e6
crates/core_simd/src/math.rs
@@ -91,11 +91,9 @@ macro_rules! impl_int_arith {
91
/// ```
92
#[inline]
93
pub fn abs(self) -> Self {
94
- let mut xs = self.to_array();
95
- for (i, x) in xs.clone().iter().enumerate() {
96
- xs[i] = x.wrapping_abs()
97
- }
98
- $name::from_array(xs)
+ const SHR: $n = <$n>::BITS as $n - 1;
+ let m = self >> SHR;
+ (self^m) - m
99
}
100
101
/// Lanewise saturating absolute value, implemented in Rust.
0 commit comments