Changes merged from Kawa's gnu.math.
* java/math/BigInteger.java * gnu/gcj/math/MPN.java (rshift0): New method handles zero shift count. (rshift(int[],int[],int,int): Removed - not needed. (gcd): Use rshift0 rather than rshift. * java/math/BigInteger.java (setShiftRight): Likewise. (divide): Simplify by using rshift0. (divide): Zero-extend results if high-order bit set. From-SVN: r40177
This commit is contained in:
parent
d6edb99e92
commit
c04278f74f
3 changed files with 44 additions and 35 deletions
|
@ -794,13 +794,7 @@ public class BigInteger extends Number implements Comparable
|
|||
xwords[xlen++] = 0;
|
||||
MPN.divide(xwords, xlen, ywords, ylen);
|
||||
rlen = ylen;
|
||||
if (remainder != null || rounding_mode != TRUNCATE)
|
||||
{
|
||||
if (nshift == 0)
|
||||
System.arraycopy(xwords, 0, ywords, 0, rlen);
|
||||
else
|
||||
MPN.rshift(ywords, xwords, 0, rlen, nshift);
|
||||
}
|
||||
MPN.rshift0 (ywords, xwords, 0, rlen, nshift);
|
||||
|
||||
qlen = xlen + 1 - ylen;
|
||||
if (quotient != null)
|
||||
|
@ -810,6 +804,12 @@ public class BigInteger extends Number implements Comparable
|
|||
}
|
||||
}
|
||||
|
||||
if (ywords[rlen-1] < 0)
|
||||
{
|
||||
ywords[rlen] = 0;
|
||||
rlen++;
|
||||
}
|
||||
|
||||
// Now the quotient is in xwords, and the remainder is in ywords.
|
||||
|
||||
boolean add_one = false;
|
||||
|
@ -1399,15 +1399,10 @@ public class BigInteger extends Number implements Comparable
|
|||
{
|
||||
if (words == null || words.length < d_len)
|
||||
realloc(d_len);
|
||||
if (count == 0)
|
||||
System.arraycopy(x.words, word_count, words, 0, d_len);
|
||||
else
|
||||
{
|
||||
MPN.rshift(words, x.words, word_count, d_len, count);
|
||||
if (neg)
|
||||
words[d_len-1] |= -1 << (32 - count);
|
||||
}
|
||||
MPN.rshift0 (words, x.words, word_count, d_len, count);
|
||||
ival = d_len;
|
||||
if (neg)
|
||||
words[d_len-1] |= -1 << (32 - count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue