summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-15 12:07:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-15 12:07:46 +0000
commitb47daf811ac057b919a12f71ac1847d16a6d464b (patch)
tree00fa9ae6920d135ddbc16b76ab395f83f74933d0 /bignum.c
parentfa1bfaf741b7281418026d10b98d874759a197a4 (diff)
* bignum.c (get2comp): do nothing for empty Bignum. [ruby-dev:31225]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 8815a43808..fb469e1a84 100644
--- a/bignum.c
+++ b/bignum.c
@@ -104,7 +104,7 @@ bigtrunc(x)
long len = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
- while (len-- && !ds[len]);
+ while (--len && !ds[len]);
RBIGNUM(x)->len = ++len;
return x;
}
@@ -1100,6 +1100,7 @@ rb_big_neg(x)
if (!RBIGNUM(x)->sign) get2comp(z);
ds = BDIGITS(z);
i = RBIGNUM(x)->len;
+ if (!i) return INT2FIX(~(SIGNED_VALUE)0);
while (i--) ds[i] = ~ds[i];
RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
if (RBIGNUM(x)->sign) get2comp(z);