Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libm-test/src/precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ fn unop_common<F1: Float, F2: Float>(
}

// abs and copysign require signaling NaNs to be propagated, so verify bit equality.
if actual.to_bits() == expected.to_bits() {
if actual.biteq(expected) {
return CheckAction::Custom(Ok(()));
} else {
return CheckAction::Custom(Err(anyhow::anyhow!("NaNs have different bitpatterns")));
Expand Down
5 changes: 1 addition & 4 deletions libm-test/src/test_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@ where
// Check when both are NaNs
if actual.is_nan() && expected.is_nan() {
if require_biteq && ctx.basis == CheckBasis::None {
ensure!(
actual.to_bits() == expected.to_bits(),
"mismatched NaN bitpatterns"
);
ensure!(actual.biteq(expected), "mismatched NaN bitpatterns");
}
// By default, NaNs have nothing special to check.
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion libm/src/math/generic/fmaximum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn fmaximum<F: Float>(x: F, y: F) -> F {
x
} else if y.is_nan() {
y
} else if x > y || (y.to_bits() == F::NEG_ZERO.to_bits() && x.is_sign_positive()) {
} else if x > y || (y.biteq(F::NEG_ZERO) && x.is_sign_positive()) {
x
} else {
y
Expand Down
11 changes: 5 additions & 6 deletions libm/src/math/generic/fmaximum_num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use crate::support::Float;

#[inline]
pub fn fmaximum_num<F: Float>(x: F, y: F) -> F {
let res =
if x.is_nan() || x < y || (x.to_bits() == F::NEG_ZERO.to_bits() && y.is_sign_positive()) {
y
} else {
x
};
let res = if x.is_nan() || x < y || (x.biteq(F::NEG_ZERO) && y.is_sign_positive()) {
y
} else {
x
};

// Canonicalize
res * F::ONE
Expand Down
2 changes: 1 addition & 1 deletion libm/src/math/generic/fminimum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn fminimum<F: Float>(x: F, y: F) -> F {
x
} else if y.is_nan() {
y
} else if x < y || (x.to_bits() == F::NEG_ZERO.to_bits() && y.is_sign_positive()) {
} else if x < y || (x.biteq(F::NEG_ZERO) && y.is_sign_positive()) {
x
} else {
y
Expand Down
11 changes: 5 additions & 6 deletions libm/src/math/generic/fminimum_num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use crate::support::Float;

#[inline]
pub fn fminimum_num<F: Float>(x: F, y: F) -> F {
let res =
if y.is_nan() || x < y || (x.to_bits() == F::NEG_ZERO.to_bits() && y.is_sign_positive()) {
x
} else {
y
};
let res = if y.is_nan() || x < y || (x.biteq(F::NEG_ZERO) && y.is_sign_positive()) {
x
} else {
y
};

// Canonicalize
res * F::ONE
Expand Down
Loading