aspose file tools
The moose likes Beginning Java and the fly likes new value for a big integer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "new value for a big integer" Watch "new value for a big integer" New topic
Author

new value for a big integer

Louise Richards
Greenhorn

Joined: Jun 28, 2001
Posts: 2
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
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
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
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).]


what?
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 155

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
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.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
 
I agree. Here's the link: http://jrebel.com/download
 
subject: new value for a big integer
 
Similar Threads
converting float hex to int
decimal to binary
Widening conversion from int to float..
BigInteger
NumberFormatException