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

java VM calculates float % NAN to be -0.0, should be NaN

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1
    • hotspot
    • x86
    • windows_nt



      Name: mc57594 Date: 01/20/97


      the following java code:
      class foo {
          public static void main( String argv[] ) {
               float f1 = 0.0f/0.0f;
               float f2 = 3.2f;
               float f3 = f1 % f2;
               float f4 = f1 * f2;

               System.out.println(f1);
               System.out.println(f2);
               System.out.println(f3);
               System.out.println(f4);
          }
      }
      produces the following incorrect output using JDK1.1beta2 and
      JCK1.1beta3.2
      NaN
      3.2
       -0.0
      NaN
      The output should be :
      NaN
      3.2
      NaN
      NaN
      which is the result given using the JDK1.1alpha VM (except that -NaN was
      displayed, but that bug got fixed). The problem is not with the compiler
      (javac), because the byte codes are correct and the class file produced
      using the JDK1.1alpha compiler also executes wrong using JDK1.1beta2 and
      JDK1.1beta3.2 VM (java.exe).
      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: