summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-04-28 13:35:22 -0700
committerJeremy Evans <code@jeremyevans.net>2021-05-08 14:45:30 -0700
commit406ae7fb03640e11e200382ef61cd450b952b7aa (patch)
tree0eb0079a16584ef1157691ebc0d3e408ead866dc /math.c
parentb7fec2e3e52e29329c0b1539d30ae0951ad6a891 (diff)
downloadruby-406ae7fb03640e11e200382ef61cd450b952b7aa.tar.gz
Fix Math.cbrt(0.0) on glibc
This should return 0, but on glibc it returned NaN. Fixes [Bug #17804]
Diffstat (limited to 'math.c')
-rw-r--r--math.c2
1 files changed, 1 insertions, 1 deletions
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