summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c3
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a8a7cf1fc..816eb8080 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jul 15 21:07:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * bignum.c (get2comp): do nothing for empty Bignum. [ruby-dev:31225]
+
Sun Jul 15 19:05:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_cstr_to_inum): check leading non-digits.
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];
}