以下代码的输出让我感到困惑。为什么NaN
有时和 Infinity 有时?
public static void main (String[] args) {
double a = 0.0;
double b = 1.0;
int c = 0;
System.out.println(a/0.0);
System.out.println(a/0);
System.out.println(b/0.0);
System.out.println(b/0);
System.out.println(c/0.0);
System.out.println(c/0);
}
输出是:
NaN
NaN
Infinity
Infinity
NaN
Exception in thread "main" java.lang.ArithmeticException: / by zero
这里的决定因素是什么?