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

Commit 16ce35b

Browse files
author
Peter Michael Green
committed
Use force_eval instead of to_bits/from_bits combination,
Using to_bits/from_bits to force conversion to storage format apparently doesn't work in release mode. Also add an architecture conditional to avoid pessimising other architectures.
1 parent 8b0db9f commit 16ce35b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/math/rem_pio2f.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ pub(crate) fn rem_pio2f(x: f32) -> (i32, f64) {
4343
if ix < 0x4dc90fdb {
4444
/* |x| ~< 2^28*(pi/2), medium size */
4545
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
46-
// use to_bits and from_bits to force rounding to storage format on
47-
// x87.
48-
let f_n = f64::from_bits((x64 * INV_PIO2 + TOINT).to_bits()) - TOINT;
46+
let tmp = x64 * INV_PIO2 + TOINT;
47+
// force rounding of tmp to it's storage format on x87 to avoid
48+
// excess precision issues.
49+
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]force_eval!(tmp);
50+
let f_n = tmp - TOINT;
4951
return (f_n as i32, x64 - f_n * PIO2_1 - f_n * PIO2_1T);
5052
}
5153
if ix >= 0x7f800000 {

0 commit comments

Comments
 (0)