Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit e1762c4

Browse files
author
Peter Michael Green
committed
round to storage format in some tests before comparison to prevent spurious errors on x87.
1 parent 705ce5f commit e1762c4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

libm/src/math/fma.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ mod tests {
218218
-0.00000000000000022204460492503126,
219219
);
220220

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

224227
#[test]

libm/src/math/pow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ mod tests {
484484
let exp = expected(*val);
485485
let res = computed(*val);
486486

487+
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(exp);
488+
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(res);
487489
assert!(
488490
if exp.is_nan() {
489491
res.is_nan()

libm/src/math/sin.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ pub fn sin(x: f64) -> f64 {
8181
fn test_near_pi() {
8282
let x = f64::from_bits(0x400921fb000FD5DD); // 3.141592026217707
8383
let sx = f64::from_bits(0x3ea50d15ced1a4a2); // 6.273720864039205e-7
84-
assert_eq!(sin(x), sx);
84+
let result = sin(x);
85+
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(result);
86+
assert_eq!(result, sx);
8587
}

0 commit comments

Comments
 (0)