Commit 12f256d4 by Tom Tromey Committed by Tom Tromey

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
parent 5d7e6254
2002-11-06 Tom Tromey <tromey@redhat.com> 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 * jni.cc (array_from_valist): Assume that jlong won't be
promoted. promoted.
......
...@@ -259,7 +259,7 @@ public int nextInt(int n) ...@@ -259,7 +259,7 @@ public int nextInt(int n)
int bits, val; int bits, val;
do do
{ {
bits = next(32); bits = next(31);
val = bits % n; val = bits % n;
} }
while(bits - val + (n-1) &lt; 0); while(bits - val + (n-1) &lt; 0);
...@@ -296,7 +296,7 @@ public int nextInt(int n) ...@@ -296,7 +296,7 @@ public int nextInt(int n)
int bits, val; int bits, val;
do do
{ {
bits = next(32); bits = next(31);
val = bits % n; val = bits % n;
} }
while (bits - val + (n - 1) < 0); while (bits - val + (n - 1) < 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment