Skip to content

Commit

Permalink
round to storage format in some tests before comparison to prevent sp…
Browse files Browse the repository at this point in the history
…urious errors on x87.
  • Loading branch information
Peter Michael Green committed Dec 22, 2021
1 parent e650f21 commit afdc1c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/math/fma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ mod tests {
-0.00000000000000022204460492503126,
);

assert_eq!(fma(-0.992, -0.992, -0.992), -0.007936000000000007,);
let result = fma(-0.992, -0.992, -0.992);
//force rounding to storage format on x87 to prevent superious errors.
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(result);
assert_eq!(result, -0.007936000000000007,);
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/math/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ mod tests {
let exp = expected(*val);
let res = computed(*val);

#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(exp);
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(res);
assert!(
if exp.is_nan() {
res.is_nan()
Expand Down
4 changes: 3 additions & 1 deletion src/math/sin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ pub fn sin(x: f64) -> f64 {
fn test_near_pi() {
let x = f64::from_bits(0x400921fb000FD5DD); // 3.141592026217707
let sx = f64::from_bits(0x3ea50d15ced1a4a2); // 6.273720864039205e-7
assert_eq!(sin(x), sx);
let result = sin(x);
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(result);
assert_eq!(result, sx);
}

0 comments on commit afdc1c5

Please sign in to comment.