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

* bignum.c (bigzero_p): check from MSB to LSB. [ruby-dev:34649]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-05-12 04:44:13 +00:00
parent e17c10a391
commit 6c1e664bb1
3 changed files with 6 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Mon May 12 13:29:26 2008 Tanaka Akira <akr@fsij.org>
* bignum.c (bigzero_p): check from MSB to LSB. [ruby-dev:34649]
Mon May 12 12:32:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (RUBYOPT): affected BASERUBY too. [ruby-talk:301514]

View file

@ -44,7 +44,7 @@ static int
bigzero_p(VALUE x)
{
long i;
for (i = 0; i < RBIGNUM_LEN(x); ++i) {
for (i = RBIGNUM_LEN(x) - 1; 0 <= i; i--) {
if (BDIGITS(x)[i]) return 0;
}
return 1;

View file

@ -632,6 +632,7 @@ struct RBignum {
(long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & \
(RBIGNUM_EMBED_LEN_MASK >> RBIGNUM_EMBED_LEN_SHIFT)) : \
RBIGNUM(b)->as.heap.len)
/* LSB:RBIGNUM_DIGITS(b)[0], MSB:RBIGNUM_DIGITS(b)[RBIGNUM_LEN(b)-1] */
#define RBIGNUM_DIGITS(b) \
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
RBIGNUM(b)->as.ary : \