Can not use subtract operator with Double.MAX_VALUE Java -
i'm trying following code:
double = double.max_value - (1000000000 * 100000000 * 1000000); system.out.println(a);
however, result still 1.7976931348623157e308
(max value of double)
can explain me?
1000000000 * 100000000 * 1000000
multiplication of 3 integers, results in overflow.
even if avoid overflow writing :
double = double.max_value - (1000000000.0 * 100000000.0 * 1000000.0);
you still see no difference since number subtracting double.max_value
negligible compared double.max_value
(~1.797*10^308, 275 orders of magnitude larger trying subtract it).
Comments
Post a Comment