Java Reference
In-Depth Information
a left shift, and vice-versa. Here again, the unsigned right shift operator
(>>) is omitted since the operation is not necessary with the infinite word
size provided by this class.
The bitwise logical operators and the comparison operators also
mimic those of Java. The BigInteger class provides modular arithmetic
operations to compute residues, perform exponentiation, and calculate
multiplicative inverses. These methods return a non-negative result, be-
tween 0 and (modulus - 1), inclusive.
BigInteger constructors
The BigInteger constructor is overloaded to provide several convenient
waysofbuildingbigintegernumbers.Theconstructorsignaturesareasfol-
lows:
BigInteger(byte[] val)
Translates a byte array containing a two's-complement binary representa-
tionintoaBigInteger.Inthisformoftheconstructorthebigintegervalueis
taken from the byte array val, which contains an integer in two's comple-
ment form. The bits are assumed to be in big-endian format. That is, val[0]
containsthemost-significantbyte.Theresultisnegativeifthemost-signifi-
cant bit of val[0] is a 1 digit.
BigInteger(int signum, byte[] magnitude)
Translatesthesign-magnituderepresentationintoaBigInteger.Inthisform
oftheconstructorthebigintegervalueistakenfromthebytearraymagni-
tude, which must contain a nonnegative binary number. The bits are as-
sumed to be in big-endian format, that is, magnitude [0] contains the
most-significant byte. If signum is -1, the result is negative. If signum is 0,
themagnitudeargumentmustcontainonlyzeros.Ifsignumis1,theresultis
positive.
BigInteger(int bitLength, int certainty, Random rnd)
Constructs a randomly generated positive BigInteger that is probably
prime, with the specified bitLength. In this form of the constructor the big
integer value is initialized with bitLength number of random bits. The
paramenter rnd is used to generate the random bits. The probability that
theresultisprimeiscontrolledbytheparametercertainty;largervaluesin-
crease the probability of a prime number's being obtained. The larger the
size of the certainty parameter the longer this constructor takes to com-
plete.
Search WWH ::




Custom Search