1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* math.c (math_log): Test the sign for bignums.

(math_log2): Ditto.
  (math_log10): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-09-07 12:34:09 +00:00
parent 08e3cb6959
commit 0e02d92371
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Sat Sep 7 21:33:10 2013 Tanaka Akira <akr@fsij.org>
* math.c (math_log): Test the sign for bignums.
(math_log2): Ditto.
(math_log10): Ditto.
Sat Sep 7 20:25:47 2013 Tanaka Akira <akr@fsij.org>
* math.c (math_log): Support bignums bigger than 2**1024.

6
math.c
View file

@ -444,7 +444,7 @@ math_log(int argc, VALUE *argv)
rb_scan_args(argc, argv, "11", &x, &base);
if (TYPE(x) == T_BIGNUM &&
if (TYPE(x) == T_BIGNUM && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));
@ -501,7 +501,7 @@ math_log2(VALUE obj, VALUE x)
double d0, d;
size_t numbits = 0;
if (TYPE(x) == T_BIGNUM &&
if (TYPE(x) == T_BIGNUM && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));
@ -540,7 +540,7 @@ math_log10(VALUE obj, VALUE x)
double d0, d;
size_t numbits = 0;
if (TYPE(x) == T_BIGNUM &&
if (TYPE(x) == T_BIGNUM && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));