I can see how to give a big integer an initial value by passing a string into its constructor. I can also see that you can point your big integer to the address of another big integer. But how can you change the contents of a big integer object once it's been created? I was expecting there to be some obvious method for this like .equals or similar but I'm having a struggle...
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
0
Hi Louise, Give up the search! BigDecimal and BigInteger were created the same as the wrapper classes: Immutable. That means that once a BigDecimal or BigInteger has a value it can't be changed! Regards, Manfred.
Louise Richards
Greenhorn
Joined: Jun 28, 2001
Posts: 2
posted
0
Thanks Manfred, seems peculiar to me to say the least, but at least I can rest easy now.
Greg Harris
Ranch Hand
Joined: Apr 12, 2001
Posts: 1012
posted
0
you can add to a BigInteger with the add() command. BigInteger = BigInteger.add( "1" ); // where "1" is some value go to java.sun.com and search for BigInteger... look through the API and you will see the add() function. [This message has been edited by Greg Harris (edited June 28, 2001).]
BigInteger bigInt = BigInteger( "23" ); bigInt = bigInt.multiply( bigInt ); Huh? Stuart [This message has been edited by Stuart Goss (edited June 28, 2001).]
rani bedi
Ranch Hand
Joined: Feb 06, 2001
Posts: 358
posted
0
All these BigInteger class functions like add, multiply, divide result in another BigInteger object. BigInteger are Immutable arbitrary-precision integers. provides analogues to all of Java's primitive integer operators, and all relevant methods from java.lang.Math. Additionally, BigInteger provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.