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

division of zero by Float.MIN_VALUE incorrectly produces NaN

XMLWordPrintable



      Name: laC46010 Date: 05/19/97



      According to JLS (15.16.2 Division Operator, p.352-353)
      0.0f / Float.MIN_VALUE is equal to 0.0f. However JIT 210.046 for JDK
      1.1.2 produces NaN as result. See log and sorce below.

      Windows95:

      [H:/ld12/java/leo/java/bug/jit/expr] jc -d . expr28301.java
      Symantec Java! JustInTime Compiler Version 210.046 for JDK 1.1.2
      Copyright (C) 1996-97 Symantec Corporation
      [H:/ld12/java/leo/java/bug/jit/expr] ja -verify expr28301
      Symantec Java! JustInTime Compiler Version 210.046 for JDK 1.1.2
      Copyright (C) 1996-97 Symantec Corporation
      expr28301: failure #4
      NaN
      NaN
      -0.0

      Solaris:

      /export/ld12/java/leo/java/bug/jit/expr_122 jc -d . expr28301.java
      /export/ld12/java/leo/java/bug/jit/expr_123 ja expr28301
      -0.0
      0.0
      -0.0

      ---------------------------------------------------------
      // Ident: @(#)expr28301.java 1.7 97/03/26
      // Copyright 03/26/97 Sun Microsystems, Inc. All Rights Reserved
      // package javasoft.sqe.tests.lang.expr283.expr28301;



      import java.io.PrintStream;
      import java.lang.Float;
      import java.lang.Double;
      import java.lang.String;


      public class expr28301 {

      public static void main(String args[]) {
      System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
      }
       
      static int errorStatus = 0/*STATUS_PASSED*/;

      static void errorAlert(PrintStream out, int errorLevel) {
      out.println("expr28301: failure #" + errorLevel);
      errorStatus = 2/*STATUS_FAILED*/;
      }

      public static int run(String args[],PrintStream out) {
      float zerof = 0.0f, resf;
      double zerod = - 0.0d, resd;

      if ((resf = zerof / 3.14f) != 0.0f)
      errorAlert(out, 2);
      else if (Float.toString(resf).startsWith("-"))
      errorAlert(out, 3);

      if ((resf = zerof / (- Float.MIN_VALUE)) != -0.0f) {
      errorAlert(out, 4);
      } else if (! Float.toString(resf).startsWith("-"))
      errorAlert(out, 5);

      out.println(zerof / - Float.MIN_VALUE);
      out.println(zerof / Float.MIN_VALUE);
      out.println(-0.0f);

      if ((resd = zerod / 0.123e-30f) != -0.0d)
      errorAlert(out, 6);
      else if (! Double.toString(resd).startsWith("-"))
      errorAlert(out, 7);

      if ((resd = - zerod / - Double.MAX_VALUE) != -0.0d)
      errorAlert(out, 8);
      else if (! Double.toString(resd).startsWith("-"))
      errorAlert(out, 9);

      return errorStatus;
      }

      }
      ---------------------------------------------------------

      ======================================================================

            dviswanasunw Deepa Viswanathan (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: