What is the maximum value of a double in Java? It is 1.7976931348623157E308,
that means 1.7976931348623157 x 10 to the power 308. If we write
System.out.println(Double.MAX_VALUE) in a Java program we can get this. Any
big number in Java is shown with an exponent field naturally. What to do if we
want to see all the digits (without the exponent) of a large number? Do you
know, if we show the numbers without exponent how large it is? How many digits
there in the above number? Unbelievably the number without exponent field
is
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368
There are 309 digits here. Can you believe it? But how can I know this? I have just written the following lines of codes in a Java program.
So we can use java.math.BigDecimal for the representation of a big numbers without the exponent field.
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368
There are 309 digits here. Can you believe it? But how can I know this? I have just written the following lines of codes in a Java program.
BigDecimal bigDecimal = new BigDecimal(Double.MAX_VALUE); String allDigits = bigDecimal.toPlainString(); System.out.println(allDigits);
So we can use java.math.BigDecimal for the representation of a big numbers without the exponent field.