ruby-changes:30792
From: akr <ko1@a...>
Date: Sat, 7 Sep 2013 21:34:21 +0900 (JST)
Subject: [ruby-changes:30792] akr:r42871 (trunk): * math.c (math_log): Test the sign for bignums.
akr 2013-09-07 21:34:09 +0900 (Sat, 07 Sep 2013) New Revision: 42871 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42871 Log: * math.c (math_log): Test the sign for bignums. (math_log2): Ditto. (math_log10): Ditto. Modified files: trunk/ChangeLog trunk/math.c Index: math.c =================================================================== --- math.c (revision 42870) +++ math.c (revision 42871) @@ -444,7 +444,7 @@ math_log(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/math.c#L444 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) https://github.com/ruby/ruby/blob/trunk/math.c#L501 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) https://github.com/ruby/ruby/blob/trunk/math.c#L540 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)); Index: ChangeLog =================================================================== --- ChangeLog (revision 42870) +++ ChangeLog (revision 42871) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Sep 7 21:33:10 2013 Tanaka Akira <akr@f...> + + * 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@f...> * math.c (math_log): Support bignums bigger than 2**1024. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/