aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/util
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-11-07 04:38:21 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-11-07 04:38:21 +0000
commit12f256d42ec080c4bc69e08636ce3b40b792eae7 (patch)
tree3bfc4bfcb8c6888b4c7c3efeaa4338352972a882 /libjava/java/util
parent5d7e6254c60224b20a3bbf480a8ab836fb19b989 (diff)
downloadgcc-12f256d42ec080c4bc69e08636ce3b40b792eae7.zip
gcc-12f256d42ec080c4bc69e08636ce3b40b792eae7.tar.gz
gcc-12f256d42ec080c4bc69e08636ce3b40b792eae7.tar.bz2
re PR libgcj/8481 (java.Random.nextInt(int) may return negative)
From svens@it.uu.se. For PR libgcj/8481. * java/util/Random.java (nextInt(int)): Only use 31 bits. From-SVN: r58876
Diffstat (limited to 'libjava/java/util')
-rw-r--r--libjava/java/util/Random.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/libjava/java/util/Random.java b/libjava/java/util/Random.java
index 500a02d..6e7d8cf 100644
--- a/libjava/java/util/Random.java
+++ b/libjava/java/util/Random.java
@@ -259,7 +259,7 @@ public int nextInt(int n)
int bits, val;
do
{
- bits = next(32);
+ bits = next(31);
val = bits % n;
}
while(bits - val + (n-1) &lt; 0);
@@ -296,7 +296,7 @@ public int nextInt(int n)
int bits, val;
do
{
- bits = next(32);
+ bits = next(31);
val = bits % n;
}
while (bits - val + (n - 1) < 0);