mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (bary_2comp): Simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c6cb7416d2
commit
69f1a3351f
2 changed files with 11 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat Jun 29 22:31:59 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bary_2comp): Simplified.
|
||||
|
||||
Sat Jun 29 09:33:53 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bigor_int): Return -1 if y == -1.
|
||||
|
|
15
bignum.c
15
bignum.c
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue