* 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
@ -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>
|
Sat Jun 29 09:33:53 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (bigor_int): Return -1 if y == -1.
|
* 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)
|
bary_2comp(BDIGIT *ds, size_t n)
|
||||||
{
|
{
|
||||||
size_t i = n;
|
size_t i = n;
|
||||||
BDIGIT_DBL num;
|
|
||||||
if (!n) return 1;
|
if (!n) return 1;
|
||||||
while (i--) ds[i] = BIGLO(~ds[i]);
|
while (i--) ds[i] = BIGLO(~ds[i]);
|
||||||
i = 0; num = 1;
|
i = 0;
|
||||||
do {
|
for (i = 0; i < n; i++) {
|
||||||
num += ds[i];
|
ds[i] = BIGLO(ds[i]+1);
|
||||||
ds[i++] = BIGLO(num);
|
if (ds[i] != 0)
|
||||||
num = BIGDN(num);
|
return 0;
|
||||||
} while (i < n);
|
}
|
||||||
return num != 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* modify a bignum by 2's complement */
|
/* modify a bignum by 2's complement */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user