summaryrefslogtreecommitdiffstats
path: root/libjava/java
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-02 06:55:33 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-02 06:55:33 +0000
commit4baba9f150e4013de41d1f05f567ff14d9af3db4 (patch)
tree30e3d7caf1e4140d48d269c9d3049f16681a89ca /libjava/java
parent9c8115261fa03f2eda5a9bfb7cb37ed4f86c4d4e (diff)
downloadppe42-gcc-4baba9f150e4013de41d1f05f567ff14d9af3db4.tar.gz
ppe42-gcc-4baba9f150e4013de41d1f05f567ff14d9af3db4.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40177 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/math/BigInteger.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/libjava/java/math/BigInteger.java b/libjava/java/math/BigInteger.java
index 0d8608eecc3..1d848d13e8f 100644
--- a/libjava/java/math/BigInteger.java
+++ b/libjava/java/math/BigInteger.java
@@ -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);
}
}
}
OpenPOWER on IntegriCloud