Which Java data type would be able to store a big numerical value, like 9999999999?
The INTEGER data type stores whole numbers that range from -2,147,483,647 to 2,147,483,647 for 9 or 10 digits of precision.
You must use BigInteger to store values that exceed the max value of long.
long long can hold up to 9223372036854775807. Use something like gmp if you need larger. Sure: if the native integer format is 128 bits, a "precisely 64 bits" type requires an &= 0xFFFFFFFFFFFFFFFF operation to be inserted at many points.
A maximum integer value that can be stored in a long long int data type is typically 9, 223, 372, 036, 854, 775, 807 around 263 – 1(but is compiler dependent). The maximum value that can be stored in long long int is stored as a constant in <climits> header file.
Your concrete example could be stored in long
(or java.lang.Long
if this is necessary).
If at any point you need bigger numbers, you can try java.math.BigInteger
(if integer), or java.math.BigDecimal
(if decimal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With