Java中NaN的困惑
2022-09-03 15:43:27
int i = 0, j = 0;
double nan1 = (double)0/0;
double nan2 = (double)0/0;
double nan3 = (double)i/j;
System.out.println(Double.doubleToRawLongBits(nan1) == Double.doubleToRawLongBits(nan2));
System.out.println(Double.doubleToRawLongBits(nan1) == Double.doubleToRawLongBits((double)0/0));
System.out.println(Double.doubleToRawLongBits(nan3) == Double.doubleToRawLongBits(nan2));
输出:
true
true
false
请帮助我前两个和最后一个的输出是如何产生的。请告诉我Double.doubleToRawLongBits()方法的实际工作是什么。true
false