summaryrefslogtreecommitdiffstats
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
commit07eb22681de5842259540d09dce6a347ce002a85 (patch)
treeca3c2568d1ac05353d0628d2d3ba6754e9196a10 /bignum.c
parent401bf544f53bdf95e02c1c456eff8ae9d570c876 (diff)
downloadruby-07eb22681de5842259540d09dce6a347ce002a85.tar.gz
ruby-07eb22681de5842259540d09dce6a347ce002a85.tar.xz
ruby-07eb22681de5842259540d09dce6a347ce002a85.zip
* bignum.c (get2comp): do nothing for empty Bignum. [ruby-dev:31225]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@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 74659dd40..36b4240de 100644
--- a/bignum.c
+++ b/bignum.c
@@ -97,7 +97,7 @@ bigtrunc(VALUE x)
long len = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
- while (len-- && !ds[len]);
+ while (--len && !ds[len]);
RBIGNUM(x)->len = ++len;
return x;
}
@@ -1038,6 +1038,7 @@ rb_big_neg(VALUE 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];
}