when we use MIN_VALUE function on either of primitive types in java it give us minimum value possible for that type. BUT in case of float and double it returned minimum positive value though float and double can have negative values also.
Double. 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.
In that case the float value containing variable may contain same data but reason behind is to mathematical rules. The only two value are consider after the point & remaining are value get neglected. so the we get two different addresses of the same data containing variables.
Wiki says this about float : The minimum positive normal value is 2^−126 ≈ 1.18 × 10^−38 and the minimum positive (denormal) value is 2^−149 ≈ 1.4 × 10^−45.
when we use MIN_VALUE function on either of primitive types in java it give us minimum value possible for that type. BUT in case of float and double it returned minimum positive value though float and double can have negative values also.
MIN_VALUE tells you how precise a float can get, but not the mathematical minimum it can represent. They should have named it better...
Negative of MAX_VALUE is the mathematical minimum value for floats(same goes for double).
The reason you can assume this has to do with how numbers are represented in binary:
Java float and doubles use sign bit to represent negative/positive values as opposed to two's complement representation for integers. This means it's positive and negative value have the same magnitude, ie. -(positive max) = negative max. Therefore you don't need to define an actual mathematical minimum constant for floats because you can just use the positive max constant to figure out the what the negative bound is. For integers, you need 2 different constants defining max/min because of the way they represented in binary, i.e. -max != min.
For more info http://people.uncw.edu/tompkinsj/133/numbers/Reals.htm
MIN_VALUE
should be named EPSILON
it's the smallest postive value a float can represent.
Because a float uses the sign-magnitude encoding, the lowest value a float can represent is -MAX_VALUE
.
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