Is this the correct way to obtain the most negative double in Java?
double v = -Double.MAX_VALUE;
If you actually want the most negative value for python, float('-inf') works nicely.
On all machines, variables of the float, double, and long double data types can store positive or negative numbers.
Smallest DOUBLE value: -1.79769E+308. Largest DOUBLE value: 1.79769E+308. Smallest positive DOUBLE value: 2.225E-307. Largest negative DOUBLE value: -2.225E-307.
MIN_VALUE is a constant holding the smallest POSITIVE nonzero value of type double, 2^(-1074). The mantissa, always a positive number, holds the significant digits of the floating-point number. The exponent indicates the positive or negative power of the radix that the mantissa and sign should be multiplied by.
Assuming you mean the largest negative, non-infinite number, sounds correct because, for floating point numbers in 64-bit IEEE 754 floating point (which is what Java uses for doubles):
Therefore: The largest representable negative number would be the same as the largest representable positive number with the sign bit flipped to indicate a negative number.
Nope, it's Double.NEGATIVE_INFINITY.
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