fix applying an error to infinities
This commit is contained in:
parent
18683c20ae
commit
8667034718
2 changed files with 8 additions and 0 deletions
|
|
@ -15,6 +15,8 @@ pub(crate) fn apply_random_float_error<F: rustc_apfloat::Float>(
|
|||
|| matches!(ecx.machine.float_rounding_error, FloatRoundingErrorMode::None)
|
||||
// relative errors don't do anything to zeros... avoid messing up the sign
|
||||
|| val.is_zero()
|
||||
// The logic below makes no sense if the input is already non-finite.
|
||||
|| !val.is_finite()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
|
@ -54,6 +56,8 @@ pub(crate) fn apply_random_float_error_ulp<F: rustc_apfloat::Float>(
|
|||
// FIXME: also disturb zeros? That requires a lot more cases in `fixed_float_value`
|
||||
// and might make the std test suite quite unhappy.
|
||||
|| val.is_zero()
|
||||
// The logic below makes no sense if the input is already non-finite.
|
||||
|| !val.is_finite()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1052,6 +1052,10 @@ pub fn libm() {
|
|||
assert_eq!(42f64.powf(0.0), 1.0);
|
||||
assert_eq!(f32::INFINITY.powf(0.0), 1.0);
|
||||
assert_eq!(f64::INFINITY.powf(0.0), 1.0);
|
||||
assert_eq!(f32::NEG_INFINITY.powi(3), f32::NEG_INFINITY);
|
||||
assert_eq!(f32::NEG_INFINITY.powi(2), f32::INFINITY);
|
||||
assert_eq!(f64::INFINITY.powi(3), f64::INFINITY);
|
||||
assert_eq!(f64::INFINITY.powi(2), f64::INFINITY);
|
||||
|
||||
// f*::NAN is a quiet NAN and should return 1 as well.
|
||||
assert_eq!(f32::NAN.powi(0), 1.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue