From b291d49de090b61c68a61b675964d0f6f6a9dff0 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 16 Jan 2026 03:35:33 +0200 Subject: [PATCH] math: fix acosh() for 0.0 (#26360) --- vlib/math/invhyp.v | 4 +--- vlib/math/math_test.v | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vlib/math/invhyp.v b/vlib/math/invhyp.v index 24c6d7f67..74c86e94b 100644 --- a/vlib/math/invhyp.v +++ b/vlib/math/invhyp.v @@ -4,9 +4,7 @@ import math.internal // acosh returns the non-negative area hyperbolic cosine of x pub fn acosh(x f64) f64 { - if x == 0.0 { - return 0.0 - } else if x > 1.0 / internal.sqrt_f64_epsilon { + if x > 1.0 / internal.sqrt_f64_epsilon { return log(x) + ln2 } else if x > 2.0 { return log(2.0 * x - 1.0 / (sqrt(x * x - 1.0) + x)) diff --git a/vlib/math/math_test.v b/vlib/math/math_test.v index 3b481c516..442578f88 100644 --- a/vlib/math/math_test.v +++ b/vlib/math/math_test.v @@ -231,8 +231,8 @@ fn test_acosh() { f := acosh(a) assert veryclose(acosh_[i], f) } - vfacosh_sc_ := [inf(-1), 0.5, 1, inf(1), nan()] - acosh_sc_ := [nan(), nan(), 0, inf(1), nan()] + vfacosh_sc_ := [inf(-1), 0.5, 0.0, 1, inf(1), nan()] + acosh_sc_ := [nan(), nan(), nan(), 0, inf(1), nan()] for i := 0; i < vfacosh_sc_.len; i++ { f := acosh(vfacosh_sc_[i]) assert alike(acosh_sc_[i], f) -- 2.39.5