Java Reference
In-Depth Information
BigInteger(int numBits, Random rnd)
ConstructsarandomlygeneratedBigInteger,uniformlydistributedover
therange0to(2 numBits-1 ),inclusive.Inthisformoftheconstructorthebigin-
tegervalueisinitializedwithnumBitsnumberofrandombits.Theparame-
terrndisusedtogeneratetherandombits.Thevalueisnevernegative.
BigInteger(String val)
TranslatesthedecimalStringrepresentationofaBigIntegerintoa
BigInteger.Inthisformoftheconstructorvalisparsedasaradix10number
toobtainthebigintegervalue.Thefirstcharactercanoptionallybeanega-
tivesign.Theparametervalmustnotcontainspacesandmustincludeat
leastonedigit.Thisconstructorformiscompatiblewiththestringsgener-
atedbythetoString()method.
BigInteger(String val, int rdix)
TranslatestheStringrepresentationofaBigIntegerinthespecifiedradix
intoaBigInteger.Inthisformoftheconstructortheparametervalisparsed
asaradixrdixnumbertoobtainthebigintegervalue.Thefirstcharacter
canoptionallycanbeanegativesign.Thestringvalmustnotcontainspaces
andmustincludeatleastonedigit.
BigInteger methods
ThereareoverfortymethodsintheBigIntegerclass . Table22-3 i ssummary
of these methods.
Table 22-3
Methods in the BigInteger Class
RETURNS
METHOD/ACTION
BigInteger abs()
Returns a BigInteger whose value is the
absolute value of this BigInteger
BigInteger add(BigInteger val)
Returns a BigInteger whose value is (this val)
BigInteger
and(BigInteger val)
Returns a BigInteger whose value is (this & val)
BigInteger
andNot(BigInteger val)
Returns a BigInteger whose value is (this &
~val)
int
bitCount()
Returns the number of bits in the two's
complement representation of this BigInteger
that differfrom its sign bit
(continues)
 
Search WWH ::




Custom Search