how big does an integer have to be that you need the big integer class to use a math function. Is there a specific rule that needs to be followed
1 Answer
It depends on the largest possible magnitude (size) of the result of the math function in your specific application as against the magnitude of an integer or a long. If you do not require absolute precision real or double may be your best choice - again this depends on your application requirements.
2 Comments
fiacobelli
Because In Java, the integer is 32 bits it ranges from -2,147,483,648 to 2,147,483,647. If you need a bigger number with no decimals (say, 3 billion) you need a Long.
Jonathan Rosenne
And a long will only do from -9223372036854775808 to 9223372036854775807, inclusive. If you need a bigger number you need a big integer.
int-type in java? Shouldn't be too hard to find an answer to that.BigInteger.ZEROis not very big.