summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 12:34:09 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 12:34:09 (GMT)
commit0e02d92371b3c3f1474195f1bfe7233b790be040 (patch)
tree1b7794db86852bc673256c1d0f107034fec9a09c /math.c
parent08e3cb6959f8f554dc86f0decddf0b54193a1a55 (diff)
* 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
Diffstat (limited to 'math.c')
-rw-r--r--math.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/math.c b/math.c
index d79a528..a804929 100644
--- a/math.c
+++ b/math.c
@@ -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));