The conversion from double to long is incorrect (according to the Java Language Specification section 5.1.3) when converting NaN. The spec says that the result should be 0, but instead is 9223372036854775807. To reproduce:
public class Bug {
public static void main(String[] args) {
long lvalue = (long)Double.NaN;
System.out.println("long value = " + lvalue);
}
}
public class Bug {
public static void main(String[] args) {
long lvalue = (long)Double.NaN;
System.out.println("long value = " + lvalue);
}
}
- duplicates
-
JDK-1229191 (math) Converting floating-point numbers to ints doesn't always work properly
-
- Closed
-