remu bugfix with -0.0 negation (#10082)

This commit is contained in:
qazal
2025-04-28 10:46:42 +03:00
committed by GitHub
parent 15e4302784
commit d6b436a815
2 changed files with 3 additions and 2 deletions

View File

@@ -56,7 +56,7 @@ where
fn negate(&self, pos: usize, modifier: usize) -> T {
match (modifier >> pos) & 1 {
1 => match self.is_zero() {
true => *self,
true => T::zero(),
false => -*self,
},
_ => *self,
@@ -123,6 +123,7 @@ mod tests {
assert_eq!(0.3_f32.negate(0, 0b110), 0.3_f32);
assert_eq!(0.3_f32.negate(1, 0b010), -0.3_f32);
assert_eq!(0.0_f32.negate(0, 0b001).to_bits(), 0);
assert_eq!((-0.0_f32).negate(0, 0b001).to_bits(), 0);
}
#[test]

View File

@@ -3019,7 +3019,7 @@ mod test_vop3 {
#[test]
fn test_v_cndmask_b32_e64_neg() {
[[0.0f32, 0.0], [1.0f32, -1.0], [-1.0f32, 1.0]].iter().for_each(|[input, ret]| {
[[0.0f32, 0.0], [-0.0f32, 0.0], [1.0f32, -1.0], [-1.0f32, 1.0]].iter().for_each(|[input, ret]| {
let mut thread = _helper_test_thread();
thread.scalar_reg[0] = false as u32;
thread.vec_reg[3] = input.to_bits();