• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

new value for a big integer

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred, seems peculiar to me to say the least, but at least I can rest easy now.
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BigInteger bigInt = BigInteger( "23" );
bigInt = bigInt.multiply( bigInt );
Huh?
Stuart
[This message has been edited by Stuart Goss (edited June 28, 2001).]
 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!