/[classpath]/classpath/gnu/java/security/util/Prime.java
ViewVC logotype

Diff of /classpath/gnu/java/security/util/Prime.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by mark, Tue Jan 22 22:26:58 2002 UTC revision 1.3.2.1 by gnu_andrew, Thu Jan 13 22:40:37 2005 UTC
# Line 1  Line 1 
1  /* Prime.java --- Prime number generation utilities  /* Prime.java --- Prime number generation utilities
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2004 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 55  public final class Prime Line 55  public final class Prime
55      BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() );      BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() );
56      if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 )      if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 )
57        {        {
58          p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) );          p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) );
59        }        }
60                    
61      //Step 2 - test for even      //Step 2 - test for even
62      if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)      if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
63        p.add( BigInteger.valueOf( 1 ) );        p = p.add( BigInteger.valueOf( 1 ) );
64    
65      for(;;)      for(;;)
66        {        {
# Line 76  public final class Prime Line 76  public final class Prime
76              // put step 2 code here so looping code is cleaner              // put step 2 code here so looping code is cleaner
77              //Step 2 - test for even              //Step 2 - test for even
78              if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)              if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
79                p.add( BigInteger.valueOf( 1 ) );                p = p.add( BigInteger.valueOf( 1 ) );
80              continue;              continue;
81            }            }
82                    
# Line 122  public final class Prime Line 122  public final class Prime
122    
123        //Step 4 - test for even        //Step 4 - test for even
124        if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)        if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
125          p.add( r );          p = p.add( r );
126    
127        for(;;)        for(;;)
128          {          {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26