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

Solaris Merlin 64-bit build with -Xcomp has bad random number distribution

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • hotspot
    • None
    • generic
    • generic

      The following test case prints out 100 random numbers and their hex
      longbits equivalents. When run with the latest Merlin builds on
      Solaris with the following options suddenly the distribution is
      skewed towards very small numbers (all numbers < 1E-10):

      % java -d64 -Xcomp randtest

      Notice that the lower 32 bits of every number are all 0 and the
      exponents are all in a very narrow range which results in numbers
      less than E-10.

      public class randtest {
          public static void main(String argv[]) {
      for (int i = 0; i < 100; i++) {
      double r = Math.random();
      System.out.println("rand["+i+"] = "+r+" == "+
      Long.toHexString(Double.doubleToLongBits(r)));
      }
          }
      }

            jrose John Rose
            flar Jim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: