Skip to content

Commit

Permalink
Merge pull request #284 from plugwash/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu authored Oct 6, 2023
2 parents 5bcbc3b + 5594834 commit 06f8ba3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/math/rint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ pub fn rint(x: f64) -> f64 {
x
} else {
let ans = if is_positive {
x + one_over_e - one_over_e
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let x = force_eval!(x);
let xplusoneovere = x + one_over_e;
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let xplusoneovere = force_eval!(xplusoneovere);
xplusoneovere - one_over_e
} else {
x - one_over_e + one_over_e
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let x = force_eval!(x);
let xminusoneovere = x - one_over_e;
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let xminusoneovere = force_eval!(xminusoneovere);
xminusoneovere + one_over_e
};

if ans == 0.0 {
Expand Down
14 changes: 12 additions & 2 deletions src/math/rintf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ pub fn rintf(x: f32) -> f32 {
x
} else {
let ans = if is_positive {
x + one_over_e - one_over_e
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let x = force_eval!(x);
let xplusoneovere = x + one_over_e;
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let xplusoneovere = force_eval!(xplusoneovere);
xplusoneovere - one_over_e
} else {
x - one_over_e + one_over_e
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let x = force_eval!(x);
let xminusoneovere = x - one_over_e;
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
let xminusoneovere = force_eval!(xminusoneovere);
xminusoneovere + one_over_e
};

if ans == 0.0 {
Expand Down

0 comments on commit 06f8ba3

Please sign in to comment.