Arrays 的sort(double[] a, int fromIndex, int toIndex) 问题
在java类库的原码中,是先调用下面一段,然后再调用排序方法的:
int numNegZeros = 0;
int i = fromIndex, n = toIndex;
while(i < n) {
if (a[i] != a[i]) {
double swap = a[i];
a[i] = a[--n];
a[n] = swap;
} else {
if (a[i]==0 && Double.doubleToLongBits(a[i])==NEG_ZERO_BITS) {
a[i] = 0.0d;
numNegZeros++;
}
i++;
}
}
我就不明白,为什么要这么做.if (a[i] != a[i]) 这种情况可能出现吗?请高手指点.