summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2023-09-13 19:21:52 +0900
committerYusuke Endoh <mame@ruby-lang.org>2023-09-13 21:40:05 +0900
commita0e66873053c2ce57a493294584da48ae600cafd (patch)
tree3a279f2f035e82214b464d9224018ba617204e03 /math.c
parent411572661a3995a0daacb6c866ea3ac6b52ad25b (diff)
Use log2(b) instead of (log(b) / M_LN2)
Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8429
Diffstat (limited to 'math.c')
-rw-r--r--math.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/math.c b/math.c
index 24e52ba59c..6cef826812 100644
--- a/math.c
+++ b/math.c
@@ -538,6 +538,7 @@ math_log_split(VALUE x, size_t *numbits)
# define log_intermediate log2
#else
# define log_intermediate log10
+double log2(double x);
#endif
VALUE
@@ -561,7 +562,7 @@ rb_math_log(int argc, const VALUE *argv)
return DBL2NUM(-0.0);
}
d = log_intermediate(d) / log_intermediate(b);
- d += (numbits - numbits_2) * M_LN2 / log(b);
+ d += (numbits - numbits_2) / log2(b);
}
else {
/* check for pole error */