Skip to content

Commit 8172c5e

Browse files
committed
fix expm1f overflow threshold
1 parent fe052cc commit 8172c5e

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

libm-test/src/precision.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,6 @@ impl MaybeOverride<(f16,)> for SpecialCase {}
218218

219219
impl MaybeOverride<(f32,)> for SpecialCase {
220220
fn check_float<F: Float>(input: (f32,), actual: F, expected: F, ctx: &CheckCtx) -> CheckAction {
221-
if ctx.base_name == BaseName::Expm1
222-
&& !input.0.is_infinite()
223-
&& input.0 > 80.0
224-
&& actual.is_infinite()
225-
&& !expected.is_infinite()
226-
{
227-
// we return infinity but the number is representable
228-
if ctx.basis == CheckBasis::Musl {
229-
return XFAIL_NOCHECK;
230-
}
231-
return XFAIL("expm1 representable numbers");
232-
}
233-
234-
if ctx.base_name == BaseName::Sinh && input.0.abs() > 80.0 && actual.is_nan() {
235-
// we return some NaN that should be real values or infinite
236-
if ctx.basis == CheckBasis::Musl {
237-
return XFAIL_NOCHECK;
238-
}
239-
return XFAIL("sinh unexpected NaN");
240-
}
241-
242221
if (ctx.base_name == BaseName::Lgamma || ctx.base_name == BaseName::LgammaR)
243222
&& input.0 > 4e36
244223
&& expected.is_infinite()

libm/src/math/expm1f.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* ====================================================
1414
*/
1515

16-
const O_THRESHOLD: f32 = 8.8721679688e+01; /* 0x42b17180 */
1716
const LN2_HI: f32 = 6.9313812256e-01; /* 0x3f317180 */
1817
const LN2_LO: f32 = 9.0580006145e-06; /* 0x3717f7d1 */
1918
const INV_LN2: f32 = 1.4426950216e+00; /* 0x3fb8aa3b */
@@ -50,7 +49,8 @@ pub fn expm1f(mut x: f32) -> f32 {
5049
if sign {
5150
return -1.;
5251
}
53-
if x > O_THRESHOLD {
52+
if hx > 0x42b17217 {
53+
/* x > log(FLT_MAX) */
5454
x *= x1p127;
5555
return x;
5656
}

0 commit comments

Comments
 (0)