Added some tests and fixed a bug
This commit is contained in:
@@ -15,7 +15,7 @@ import java.util.TimerTask;
|
||||
*/
|
||||
public abstract class MainProcess {
|
||||
|
||||
private final static String VERSION = "v1.2";
|
||||
private final static String VERSION = "v1.3";
|
||||
|
||||
private final static SimpleDateFormat DATE_TO_NUM = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
|
||||
|
||||
@@ -86,8 +86,10 @@ public abstract class PrimeCalculator {
|
||||
long end = start + BLOCK_MAX;
|
||||
long endSqrt = (long) Math.sqrt(end) + 1;
|
||||
|
||||
System.out.println(number);
|
||||
|
||||
byte block = 0;
|
||||
int p = 3;
|
||||
int p = 2;
|
||||
while (p < endSqrt) {
|
||||
p = nextPrime(p);
|
||||
|
||||
@@ -102,6 +104,9 @@ public abstract class PrimeCalculator {
|
||||
}
|
||||
byte mask = (byte) (1 << ((number >> 1) & 7));
|
||||
|
||||
System.out.println(byteToBinary(block));
|
||||
System.out.println(byteToBinary(mask));
|
||||
|
||||
return !((block & mask) != 0);
|
||||
}
|
||||
|
||||
@@ -125,5 +130,9 @@ public abstract class PrimeCalculator {
|
||||
return !getBit(number);
|
||||
return isPrimeByBlock(number);
|
||||
}
|
||||
|
||||
public static String byteToBinary(byte b) {
|
||||
return String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user