>From ecc6e727bd69c68c45e5ff1372292036a36c3aad Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Mon, 3 Aug 2026 10:49:22 +0000 Subject: [PATCH 2/2] math: make acoshf consistent with acosh --- src/math/acoshf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/math/acoshf.c b/src/math/acoshf.c index b773d48e..1c1b7096 100644 --- a/src/math/acoshf.c +++ b/src/math/acoshf.c @@ -12,15 +12,16 @@ float acoshf(float x) { union {float f; uint32_t i;} u = {x}; - uint32_t a = u.i & 0x7fffffff; - if (a < 0x3f800000+(1<<23)) - /* |x| < 2, invalid if x < 1 */ + if (u.i < 0x3f800000+(1<<23)) + /* 0 <= x < 2, invalid if x < 1 */ /* up to 2ulp error in [1,1.125] */ return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1))); if (u.i < 0x3f800000+(12<<23)) /* 2 <= x < 0x1p12 */ return logf(2*x - 1/(x+sqrtf(x*x-1))); - /* x >= 0x1p12 or x <= -2 or nan */ + if (u.i & 0x80000000) + return (x-x)/(x-x); + /* x >= 0x1p12 or nan */ return logf(x) + 0.693147180559945309417232121458176568f; } -- 2.52.0