-3

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

OneStepBeyond
  • 21
  • 1
  • 8
  • Look up the API for the Integer class -- it's all there. Also simply Google java primitive types tutorials, and it will likely be there as well. – Hovercraft Full Of Eels Feb 19 '16 at 20:03
  • So you want to know about the boundaries of the `int`-type in java? Shouldn't be too hard to find an answer to that. –  Feb 19 '16 at 20:06
  • Strictly speaking, it doesn't have to be that big. `BigInteger.ZERO` is not very big. – Tunaki Feb 19 '16 at 20:06
  • i could not find a question similar, there were some that talked about using big integer but it was more in applying it for programming i meant just generally when do you need to use it – OneStepBeyond Feb 19 '16 at 21:51

1 Answers1

0

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.

Jonathan Rosenne
  • 2,159
  • 17
  • 27
  • 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. – fiacobelli Feb 27 '16 at 03:57
  • And a long will only do from -9223372036854775808 to 9223372036854775807, inclusive. If you need a bigger number you need a big integer. – Jonathan Rosenne Feb 28 '16 at 05:46