I'm trying to use the BigInteger class in package java.math.BigInteger. A BigInteger is an arbitrary precision twos compliment binary number; it is for numbers that will not fit in a long. There are several constructors providing several ways to assign the initial value to a newly created BigInteger, and a static method, valueOf, that returns the BigInteger form of a specified long. There does not seem to be a direct way to get the initial value from another BigInteger. Does anyone know why? I can work around this omission by setting the value to zero, and adding the desired initial value. I suspect this is not a java design bug, but rather that I'm thinking wrong.
What should I do instead? BigInteger is not Cloneable. Thanks.
You missed one important feature of BigInteger -- namely that it's immutable. Therefore it isn't necessary to make copies of BigInteger objects. Just give your new variable a reference to an existing BigInteger object, that's all you need.
Joined: Oct 04, 2009
You are right, I missed the "immutable". Suppose x is an array of BigInteger. I want to compute x[i] = (x[j] + x[k]) *x[n] for various values of j, k, and n that are less than i and functions of i. The value of the reference at x[i] will change several times as I compute the value. The garbage collector will have a lot of work to do. Perhaps it will not be too much work. I won't worry until I feel some pain. Thanks for the quick help.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Initial value for BigInteger from another BigInteger