From 9dd86a2de6541a36889c1253d4dae515aed727fe Mon Sep 17 00:00:00 2001 From: Kaito Sugimoto <7x.rusk@gmail.com> Date: Mon, 16 Dec 2019 01:37:17 +0900 Subject: [PATCH] math: fix abs (-0.0) --- vlib/math/math.v | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vlib/math/math.v b/vlib/math/math.v index 286402b0b1..b74dc95597 100644 --- a/vlib/math/math.v +++ b/vlib/math/math.v @@ -18,6 +18,7 @@ fn C.erf(x f64) f64 fn C.erfc(x f64) f64 fn C.exp(x f64) f64 fn C.exp2(x f64) f64 +fn C.fabs(x f64) f64 fn C.floor(x f64) f64 fn C.fmod(x f64, y f64) f64 fn C.hypot(x f64, y f64) f64 @@ -42,10 +43,7 @@ fn C.trunc(x f64) f64 // Returns the absolute value. pub fn abs(a f64) f64 { - if a < 0 { - return -a - } - return a + return C.fabs(a) } // acos calculates inverse cosine (arccosine).