From 406ae7fb03640e11e200382ef61cd450b952b7aa Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 28 Apr 2021 13:35:22 -0700 Subject: Fix Math.cbrt(0.0) on glibc This should return 0, but on glibc it returned NaN. Fixes [Bug #17804] --- math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'math.c') diff --git a/math.c b/math.c index 470979c424..3b72149feb 100644 --- a/math.c +++ b/math.c @@ -703,7 +703,7 @@ math_cbrt(VALUE unused_obj, VALUE x) double f = Get_Double(x); double r = cbrt(f); #if defined __GLIBC__ - if (isfinite(r)) { + if (isfinite(r) && !(f == 0.0 && r == 0.0)) { r = (2.0 * r + (f / r / r)) / 3.0; } #endif -- cgit v1.2.1