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

wrong conversion of floating-point MAX_VALUE and Infinity to integral types

XMLWordPrintable



      Name: laC46010 Date: 05/19/97



      According to JLS (5.1.3 Narrowing Conversions, p.55-57)
      (byte)Double.MAX_VALUE is equal to -1. However JIT 210.046 for JDK
      1.1.2 produces 0 as result. See log and sorce below.

      Windows95:

      [H:/ld12/java/leo/java/bug/jit/expr] jc -d . type*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 type02101
      Symantec Java! JustInTime Compiler Version 210.046 for JDK 1.1.2
      Copyright (C) 1996-97 Symantec Corporation
      0
      -1
      Failed.

      Solaris:

      /export/ld12/java/leo/java/bug/jit/expr_109 ja -version
      java version "1.1.2"
      /export/ld12/java/leo/java/bug/jit/expr_110 ja type02101
      -1
      -1
      Passed.

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

      public class type02101 {
      public static void main(String args[]) {
      double d = Double.MAX_VALUE;
      if ((byte) d != (byte) 0xFF){
      System.out.println((byte) d);
      System.out.println((byte) 0xFF);
      System.out.println("Failed.");
      } else {
      System.out.println((byte) d);
      System.out.println((byte) 0xFF);
      System.out.println("Passed.");
      }
      }

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

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

      Name: laC46010 Date: 10/07/97



      The following JCK-114a language tests fails on Windows under JDK1.1.4 with JIT v. 57:

      lang/CONV/conv009/conv00906/conv00906.html
      lang/CONV/conv015/conv01504/conv01504.html
      lang/CONV/conv015/conv01505/conv01505.html
      lang/CONV/conv015/conv01510/conv01510.html
      lang/CONV/conv015/conv01511/conv01511.html
      lang/TYPE/type021/type02101/type02101.html


      All these failures are caused with incorrect result of conversion
      of various float values to integral types. Sometimes it produces 0
      as result sometimes other incorrect values.

      Tests outputs are cited below with corresponding excerpts
      from test sources:

      lang/CONV/conv009/conv00906/conv00906.html
      conv00906: failure #7
                      if ((byte) Float.MAX_VALUE != (byte) 0xFF)
                              errorAlert(out, 7);

      lang/CONV/conv015/conv01504/conv01504.html
      conv01504: failure #17
      conv01504: failure #18
      conv01504: failure #19
      conv01504: failure #20
      conv01504: failure #21
                      float f = Float.MAX_VALUE;

                      if ((byte) f != (byte) 0xFF)
                              errorAlert(out, 17);
                      if ((short) f != (short) 0xFFFF)
                              errorAlert(out, 18);
                      if ((char) f != '\uFFFF')
                              errorAlert(out, 19);
                      if ((int) f != 2147483647)
                              errorAlert(out, 20);
                      if ((long) f != 9223372036854775807l)
                              errorAlert(out, 21);

      lang/CONV/conv015/conv01505/conv01505.html
      conv01505: failure #22
      conv01505: failure #23
      conv01505: failure #24
      conv01505: failure #25
      conv01505: failure #26

                      float f = Float.POSITIVE_INFINITY;

                      if ((byte) f != (byte) 0xFF)
                              errorAlert(out, 22);
                      if ((short) f != (short) 0xFFFF)
                              errorAlert(out, 23);
                      if ((char) f != '\uFFFF')
                              errorAlert(out, 24);
                      if ((int) f != 2147483647)
                              errorAlert(out, 25);
                      if ((long) f != 9223372036854775807l)
                              errorAlert(out, 26);


      lang/CONV/conv015/conv01510/conv01510.html
      conv01510: failure #47
      conv01510: failure #48
      conv01510: failure #49
      conv01510: failure #50
      conv01510: failure #51
                      double d = Double.MAX_VALUE;

                      if ((byte) d != (byte) 0xFF)
                              errorAlert(out, 47);
                      if ((short) d != (short) 0xFFFF)
                              errorAlert(out, 48);
                      if ((char) d != '\uFFFF')
                              errorAlert(out, 49);
                      if ((int) d != 2147483647)
                              errorAlert(out, 50);
                      if ((long) d != 9223372036854775807l)
                              errorAlert(out, 51);

      lang/CONV/conv015/conv01511/conv01511.html
      conv01511: failure #52
      conv01511: failure #53
      conv01511: failure #54
      conv01511: failure #55
      conv01511: failure #56
                      double d = Double.POSITIVE_INFINITY;

                      if ((byte) d != (byte) 0xFF)
                              errorAlert(out, 52);
                      if ((short) d != (short) 0xFFFF)
                              errorAlert(out, 53);
                      if ((char) d != '\uFFFF')
                              errorAlert(out, 54);
                      if ((int) d != 2147483647)
                              errorAlert(out, 55);
                      if ((long) d != 9223372036854775807l)
                              errorAlert(out, 56);


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

            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: