Commit b6e9851a by Tom Tromey Committed by Andreas Tobler

Prime.java (generateRandomPrime): Use return result from `add'.

2004-08-30  Tom Tromey  <tromey@redhat.com>

	* gnu/java/security/util/Prime.java (generateRandomPrime): Use
	return result from `add'.

From-SVN: r86787
parent a23adb4d
2004-08-30 Tom Tromey <tromey@redhat.com> 2004-08-30 Tom Tromey <tromey@redhat.com>
* gnu/java/security/util/Prime.java (generateRandomPrime): Use
return result from `add'.
2004-08-30 Tom Tromey <tromey@redhat.com>
* java/rmi/server/UID.java (UID): Read `nextCount', not count. * java/rmi/server/UID.java (UID): Read `nextCount', not count.
2004-08-30 Andreas Tobler <a.tobler@schweiz.ch> 2004-08-30 Andreas Tobler <a.tobler@schweiz.ch>
......
/* Prime.java --- Prime number generation utilities /* Prime.java --- Prime number generation utilities
Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -55,12 +55,12 @@ public final class Prime ...@@ -55,12 +55,12 @@ public final class Prime
BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() ); BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() );
if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 ) if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 )
{ {
p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) ); p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) );
} }
//Step 2 - test for even //Step 2 - test for even
if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
p.add( BigInteger.valueOf( 1 ) ); p = p.add( BigInteger.valueOf( 1 ) );
for(;;) for(;;)
{ {
...@@ -76,7 +76,7 @@ public final class Prime ...@@ -76,7 +76,7 @@ public final class Prime
// put step 2 code here so looping code is cleaner // put step 2 code here so looping code is cleaner
//Step 2 - test for even //Step 2 - test for even
if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
p.add( BigInteger.valueOf( 1 ) ); p = p.add( BigInteger.valueOf( 1 ) );
continue; continue;
} }
...@@ -122,7 +122,7 @@ public final class Prime ...@@ -122,7 +122,7 @@ public final class Prime
//Step 4 - test for even //Step 4 - test for even
if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
p.add( r ); p = p.add( r );
for(;;) for(;;)
{ {
......
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