mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
81fc1cf201
commit
bc2fb51c5e
2 changed files with 17 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Feb 22 19:50:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
|
||||||
|
|
||||||
Fri Feb 22 15:47:36 2008 Tanaka Akira <akr@fsij.org>
|
Fri Feb 22 15:47:36 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* encoding.c (rb_enc_mbclen): return minlen instead of 1 when
|
* encoding.c (rb_enc_mbclen): return minlen instead of 1 when
|
||||||
|
|
14
bignum.c
14
bignum.c
|
@ -36,7 +36,19 @@ VALUE rb_cBignum;
|
||||||
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
|
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
|
||||||
#define BDIGMAX ((BDIGIT)-1)
|
#define BDIGMAX ((BDIGIT)-1)
|
||||||
|
|
||||||
#define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || (RBIGNUM_LEN(x) == 1 && BDIGITS(x)[0] == 0))
|
#define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || \
|
||||||
|
(BDIGITS(x)[0] == 0 && \
|
||||||
|
(RBIGNUM_LEN(x) == 1 || bigzero_p(x))))
|
||||||
|
|
||||||
|
static int
|
||||||
|
bigzero_p(VALUE x)
|
||||||
|
{
|
||||||
|
long i;
|
||||||
|
for (i = 0; i < RBIGNUM_LEN(x); ++i) {
|
||||||
|
if (BDIGITS(x)[i]) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#define RBIGNUM_SET_LEN(b,l) \
|
#define RBIGNUM_SET_LEN(b,l) \
|
||||||
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
|
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
|
||||||
|
|
Loading…
Reference in a new issue