diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-15 12:07:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-15 12:07:46 +0000 |
commit | 65055630acd67e9d85b30646c9311e7d214f8912 (patch) | |
tree | ca3c2568d1ac05353d0628d2d3ba6754e9196a10 | |
parent | b64881077e272f421759149bff40e8d472621423 (diff) | |
download | ruby-65055630acd67e9d85b30646c9311e7d214f8912.tar.gz |
* bignum.c (get2comp): do nothing for empty Bignum. [ruby-dev:31225]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | bignum.c | 3 |
2 files changed, 6 insertions, 1 deletions
@@ -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. @@ -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]; } |