5、Java.math.BitSieve
字节过滤类,
class BitSieve
private long bits[] //存储bit过滤Storesthe bits in this bitSieve.
private int length //Length is how many bits this sieve holds.
private static BitSieve smallSieve = new BitSieve() //A small sieve used tofilter out multiples of small primes in a search sieve.
private BitSieve()
BitSieve(BigInteger base, int searchLen) //Construct a bit sieve of searchLenbits used for finding prime number candidates.
private static int unitIndex(int bitIndex) //Given a bitindex return unit index containing it.
private static long bit(int bitIndex) //Return a unit that masks the specifiedbit in its unit.
private boolean get(int bitIndex) //Get the value of thebit at the specified index.
private void set(int bitIndex) //Set the bit at the specified index.
private int sieveSearch(int limit, int start) //returns the index of thefirst clear bit in the search array
private void sieveSingle(int limit, int start, int step) //Sieve a single setof multiples out of the sieve.
BigInteger retrieve(BigInteger initValue, int certainty, java.util.Randomrandom) //Test probable primes in the sieve and return successful candidates.
6、java.math.MutableBigInteger
可变的BigInteger
class MutableBigInteger
int[] value
int intLen
int offset = 0
private final static long LONG_MASK = 0xffffffffL
MutableBigInteger()
MutableBigInteger(int val)
MutableBigInteger(int[] val, int len)
MutableBigInteger(int[] val)
MutableBigInteger(BigInteger b)
MutableBigInteger(MutableBigInteger val)
void clear()
void reset()
final int compare(MutableBigInteger b) //比较
private final int getLowestSetBit()
private final int getInt(int index)
private final long getLong(int index)
final void normalize()
private final void ensureCapacity(int len)
int[] toIntArray()
void setInt(int index, int val)
void setValue(int[] val, int length)
void copyValue(MutableBigInteger val)
void copyValue(int[] val)
boolean isOne()
boolean isZero()
boolean isEven()
boolean isOdd()
boolean isNormal()
public String toString()
void rightShift(int n)
void leftShift(int n)
private int divadd(int[] a, int[] result, int offset)
private int mulsub(int[] q, int[] a, int x, int len, int offset)
private final void primitiveRightShift(int n)
private final void primitiveLeftShift(int n)
void add(MutableBigInteger addend)
int subtract(MutableBigInteger b)
private int difference(MutableBigInteger b)
void multiply(MutableBigInteger y, MutableBigInteger z)
void mul(int y, MutableBigInteger z)
void divideOneWord(int divisor, MutableBigInteger quotient)
void divide(MutableBigInteger b,MutableBigInteger quotient, MutableBigIntegerrem)
private boolean unsignedLongCompare(long one, long two)
private void divWord(int[] result, long n, int d)
MutableBigInteger hybridGCD(MutableBigInteger b)//Calculate GCD of this and b.
private MutableBigInteger binaryGCD(MutableBigInteger v) //Calculate GCD ofthis and v.
static int binaryGcd(int a, int b) //Calculate GCD of a and b interpreted asunsigned integers.
MutableBigInteger mutableModInverse(MutableBigInteger p)//the modInverse of this mod p.
MutableBigInteger modInverseMP2(int k) // inverse of this mod 2^k
static int inverseMod32(int val) //inverse of val mod 2^32
static MutableBigInteger modInverseBP2(MutableBigInteger mod, int k) //inverseof 2^k mod mod
private MutableBigInteger modInverse(MutableBigInteger mod)
static MutableBigInteger fixup(MutableBigInteger c, MutableBigInteger p,int k)//X = C * 2^(-k) (mod P)
MutableBigInteger euclidModInverse(int k) //mod a modulus that is a power of 2
7、java.math.SignedMutableBigInteger
有符号的可变的BigInteger
class SignedMutableBigInteger extends MutableBigInteger
int sign = 1
SignedMutableBigInteger()
SignedMutableBigInteger(int val)
SignedMutableBigInteger(MutableBigInteger val)
方法:
void signedAdd(SignedMutableBigInteger addend) //加
void signedAdd(MutableBigInteger addend) //加
void signedSubtract(SignedMutableBigInteger addend) //减
void signedSubtract(MutableBigInteger addend) //减
public String toString()
Java jdk源代码的Math包(3)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/3ee35690b3a0cc949d38cc9fd22db142.html