Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4174442

Floating point NaN to int conversion is not done correctly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.2.0
    • hotspot
    • sparc
    • solaris_2.6


      allan.jacobs@Eng 1998-09-17

      Floating point NaN's should be converted to int or long 0 in narrowing primitive
      and casting conversions. Conversions to int are not done correctly.


      algol% ${JDK}/bin/java -fullversion
      java full version "JDK-1.2fcs-J"
      algol% uname -a
      SunOS algol 5.6 Generic sun4u sparc SUNW,Ultra-2
      algol% ${JDK}/bin/javac -d . X.java
      algol% ${JDK}/bin/java -verify X
      NaN NaN
      2147483647 2147483647
      0 0
      algol% cat X.java

      public class X {
      public static void main( String[] argv ) {
              double d1=Double.NaN;
              double f1=Float.NaN;
              System.out.println(f1+" "+d1);
              System.out.println(((int)d1)+" "+((int)f1));
              System.out.println(((long)d1)+" "+((long)f1));
      }
      }

            tlindholsunw Timothy Lindholm (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: