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
This commit is contained in:
Tom Tromey 2002-11-07 04:38:21 +00:00 committed by Tom Tromey
parent 5d7e6254c6
commit 12f256d42e
2 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2002-11-06 Tom Tromey <tromey@redhat.com>
From svens@it.uu.se. For PR libgcj/8481.
* java/util/Random.java (nextInt(int)): Only use 31 bits.
2002-11-06 Tom Tromey <tromey@redhat.com>
* jni.cc (array_from_valist): Assume that jlong won't be

View File

@ -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);