diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-29 13:33:40 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-29 13:33:40 +0000 |
commit | 69f1a3351fe731e8d92c2f1c7f8507c08fb7e59b (patch) | |
tree | 81689a9538af14f464a71a77a7e7c3ad8b2bbf48 /bignum.c | |
parent | c6cb7416d21e348a44cf17dad0c603d1c6a23a8b (diff) | |
download | ruby-69f1a3351fe731e8d92c2f1c7f8507c08fb7e59b.tar.gz |
* bignum.c (bary_2comp): Simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -271,16 +271,15 @@ static int bary_2comp(BDIGIT *ds, size_t n) { size_t i = n; - BDIGIT_DBL num; if (!n) return 1; while (i--) ds[i] = BIGLO(~ds[i]); - i = 0; num = 1; - do { - num += ds[i]; - ds[i++] = BIGLO(num); - num = BIGDN(num); - } while (i < n); - return num != 0; + i = 0; + for (i = 0; i < n; i++) { + ds[i] = BIGLO(ds[i]+1); + if (ds[i] != 0) + return 0; + } + return 1; } /* modify a bignum by 2's complement */ |