diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-15 20:44:55 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-15 20:44:55 +0000 |
commit | 3d61f7c3d335306443781d8c975e330a1ce26ada (patch) | |
tree | 5ac53ea4b409c0a4ea029d1eb7f0c83cc5ecdb2d /bignum.c | |
parent | 404f77ec0b595ea8279750dbd5082f7bed14877f (diff) |
* bignum.c (bignorm): do not empty Bignum. [ruby-dev:31229]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@12990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -74,6 +74,7 @@ get2comp(x) BDIGIT *ds = BDIGITS(x); BDIGIT_DBL num; + if (!i) return; while (i--) ds[i] = ~ds[i]; i = 0; num = 1; do { @@ -106,7 +107,7 @@ bignorm(x) long len = RBIGNUM(x)->len; BDIGIT *ds = BDIGITS(x); - while (len-- && !ds[len]) ; + while (--len && !ds[len]) ; RBIGNUM(x)->len = ++len; if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) { @@ -1059,6 +1060,7 @@ rb_big_neg(x) if (!RBIGNUM(x)->sign) get2comp(z); ds = BDIGITS(z); i = RBIGNUM(x)->len; + if (!i) return INT2FIX(~0); while (i--) ds[i] = ~ds[i]; RBIGNUM(z)->sign = !RBIGNUM(z)->sign; if (RBIGNUM(x)->sign) get2comp(z); |