diff --git a/ChangeLog b/ChangeLog index 56aad041a9..1d2906347f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon May 12 13:29:26 2008 Tanaka Akira + + * bignum.c (bigzero_p): check from MSB to LSB. [ruby-dev:34649] + Mon May 12 12:32:10 2008 Nobuyoshi Nakada * common.mk (RUBYOPT): affected BASERUBY too. [ruby-talk:301514] diff --git a/bignum.c b/bignum.c index 536094f23a..277923f551 100644 --- a/bignum.c +++ b/bignum.c @@ -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; diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index c3696ff866..5707571cfa 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -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 : \