summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 20:44:55 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 20:44:55 +0000
commit3d61f7c3d335306443781d8c975e330a1ce26ada (patch)
tree5ac53ea4b409c0a4ea029d1eb7f0c83cc5ecdb2d /bignum.c
parent404f77ec0b595ea8279750dbd5082f7bed14877f (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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 473434d18e..0ff4b4e19f 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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);