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

Win32 double reader can't handle full range of values

XMLWordPrintable

    • 1.2beta4
    • generic, sparc
    • generic, solaris_2.4, solaris_2.5
    • Not verified

      Execution result of byte code generated on Win32 is incorrect.
      Could not handle a value "4.94065645841246544e-324" properly.

      import java.text.*;

      public class minval{
          public static void main(String[] args){
              double d1 = Double.MIN_VALUE;
              double d2 = 4.94065645841246544e-324;
              if(d1 != d2){
                  System.out.println("NG");
                  System.out.println(d1+" "+Double.doubleToLongBits(d1));
                  System.out.println(d2+" "+Double.doubleToLongBits(d2));
              }else
                  System.out.println("OK");
          }
      }

      If above code is compiled on Solaris then gets exptected result.
      But if Win32 then gets unexpected result.

      sishida@stones[293] java minval <--bytecode compiled on Solaris
      OK
      sishida@stones[294] java minval <--on Win32
      NG
      4.9E-324 1
      1.0E-323 2

      From a redundant report (4031719), another test case:

      The following delightful java program:

      public class Bug {
          public static void main (String[] args) {
      String doubleMinVal =
      "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625";

          double minVal = Double.valueOf(doubleMinVal).doubleValue();

          System.out.println("Double: " + minVal);
          System.out.println("Long bits: " + Double.doubleToLongBits(minVal));
          }
      }

      produces this (correct) output on Solaris:

      Double: 4.9E-324
      Long bits: 1

      and this (bogus) output on win32:

      Double: 1.0E-323
      Long bits: 2

            hongzh Hong Zhang
            sishidasunw Shoji Ishida (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: