Seen source code of Double.java and some constants are like
/**
* Constant for the Not-a-Number (NaN) value of the {@code double} type.
*/
public static final double NaN = 0.0 / 0.0;
/**
* Constant for the positive infinity value of the {@code double} type.
*/
public static final double POSITIVE_INFINITY = 1.0 / 0.0;
/**
* Constant for the negative infinity value of the {@code double} type.
*/
public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
but I wonder why it is not throwing ArithmeticException(divide by zero)?
and I have tried
public static final int VALUE = 0/0;
now it's throwing Exception but when I say
public static final double VALUE = 0d/0d;
it is not throwing exception...
What's the magic of Double
and why it is not throwing Exception?