-
Bug
-
Resolution: Fixed
-
P1
-
1.0.2, 1.1
-
1.1
-
sparc
-
solaris_2.4
-
Not verified
Name: swC45995 Date: 10/07/96
In Windows java incorrectly converts floating-point values to integral types.
In particular, NaN is not converted to zero, the maximum double value is
converted to the minimum long value and zeros of other integral types, etc.
Thus execution of the following test:
public class test
{
public static void main(String argv[])
{
System.out.println((byte) Float.MAX_VALUE);
System.out.println((short) Float.MAX_VALUE);
System.out.println((int) (char) Float.MAX_VALUE);
System.out.println((int) Float.MAX_VALUE);
System.out.println((long) Float.MAX_VALUE);
System.out.println((long) Float.MAX_NaN);
}
}
produces the following results:
0
0
0
0
-9223372036854775808
-9223372036854775808
instead of expected:
-1
-1
65535
2147483647
9223372036854775807
0
For double values the results will be the same.
======================================================================
- relates to
-
JDK-1229191 (math) Converting floating-point numbers to ints doesn't always work properly
-
- Closed
-
-
JDK-1266773 wrong narrowing primitive conversion
-
- Closed
-
-
JDK-1266803 wrong narrowing primitive conversion
-
- Closed
-
-
JDK-1266804 wrong narrowing primitive conversion
-
- Closed
-