diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-22 01:11:29 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-22 01:11:29 +0000 |
commit | d47a4403bf19818f3bc66bd254f84fa823e88aa9 (patch) | |
tree | c729d3335767305125b6f827e0ff1b733cc312c0 /bignum.c | |
parent | b441a68e7fad7c5f0d3556aba15deea970aed8a5 (diff) |
* bignum.c (rb_big_neg): SIGNED_VALUE isn't in 1.8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13172 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 { @@ -102,7 +103,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; } @@ -1086,6 +1087,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); |