summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2023-09-13 18:56:24 +0900
committerYusuke Endoh <[email protected]>2023-09-13 21:40:05 +0900
commit411572661a3995a0daacb6c866ea3ac6b52ad25b (patch)
tree377a8f96e33f6a412df37d8315c168b01f0ab5fb /math.c
parent4655d2108ef14e66f64496f9029f65ba2302d9ea (diff)
math.c: Fix Math.log against huge bignum [Bug #19878]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8429
Diffstat (limited to 'math.c')
-rw-r--r--math.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/math.c b/math.c
index 6f0ddf9ec5..24e52ba59c 100644
--- a/math.c
+++ b/math.c
@@ -561,14 +561,14 @@ rb_math_log(int argc, const VALUE *argv)
return DBL2NUM(-0.0);
}
d = log_intermediate(d) / log_intermediate(b);
- numbits -= numbits_2;
+ d += (numbits - numbits_2) * M_LN2 / log(b);
}
else {
/* check for pole error */
if (d == 0.0) return DBL2NUM(-HUGE_VAL);
d = log(d);
+ d += numbits * M_LN2;
}
- d += numbits * M_LN2;
return DBL2NUM(d);
}