My experimentation suggests a bound of 24, which is reached by -Double.MIN_NORMAL, which results in
-2.2250738585072014E-308
...but I can't prove it, nor come up with a conclusive reason why no other value should beat -MIN_NORMAL.
MAX_VALUE. A constant holding the largest positive finite value of type double , (2-2-52)·21023. It is equal to the hexadecimal floating-point literal 0x1.
Double: The C++ double is also a primitive data type that is used to store floating-point values up to 15 digits. In the above example, variables of float and double types are initialized with floating-point values.
It's a 64-bit IEEE-754 float.
The most decimal numbers that can be stored in a 52-bit mantissa is 17 (see page 4: ceil( 1 + N Log10(2) )), so that's 19 characters with the decimal point and negative sign.
The bias is 1023, so the smallest base-2 exponent is 2^-1022, which is around 10^-308, so the longest exponent is 5 characters with the 'E' and negative sign.
19 + 5 == 24
26 seems to be an upper bound, for certain, as follows.
According to GrepCode's version of FloatingDecimal.getChars, OpenJDK7 asserts that the value nDigits is at most 19. Looking at the code, nDigits appears to refer to the digits (not the decimal point) of the mantissa: in the above example, 22250738585072014. Additional characters, then, include
- sign on the value as a whole. decimal pointE for the exponent- sign on the exponent... which makes 19 + 7 = 26.
(Arguments for tighter bounds are still welcome.)
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