src/java.base/share/classes/java/util/random/Xoshiro256StarStar.java
branchJDK-8193209-branch
changeset 59080 1b314be4feb2
parent 57684 7cb325557832
equal deleted inserted replaced
57940:7e791393cc4d 59080:1b314be4feb2
   231      * Returns a pseudorandom {@code long} value.
   231      * Returns a pseudorandom {@code long} value.
   232      *
   232      *
   233      * @return a pseudorandom {@code long} value
   233      * @return a pseudorandom {@code long} value
   234      */
   234      */
   235    public long nextLong() {
   235    public long nextLong() {
   236         final long z = x0;
   236        // Compute the result based on current state information
   237         long q0 = x0, q1 = x1, q2 = x2, q3 = x3;
   237        // (this allows the computation to be overlapped with state update).
       
   238        final long result = Long.rotateLeft(x0 * 5, 7) * 9;  // "starstar" mixing function
       
   239        
       
   240        long q0 = x0, q1 = x1, q2 = x2, q3 = x3;
   238        {   // xoshiro256 1.0
   241        {   // xoshiro256 1.0
   239            long t = q1 << 17;
   242            long t = q1 << 17;
   240            q2 ^= q0;
   243            q2 ^= q0;
   241            q3 ^= q1;
   244            q3 ^= q1;
   242            q1 ^= q2;
   245            q1 ^= q2;
   243            q0 ^= q3;
   246            q0 ^= q3;
   244            q2 ^= t;
   247            q2 ^= t;
   245            q3 = Long.rotateLeft(q3, 45);
   248            q3 = Long.rotateLeft(q3, 45);
   246        }
   249        }
   247         x0 = q0; x1 = q1; x2 = q2; x3 = q3;
   250         x0 = q0; x1 = q1; x2 = q2; x3 = q3;
   248         return Long.rotateLeft(z * 5, 7) * 9;  // "starstar" mixing function
   251         return result;
   249     }
   252     }
   250 
   253 
   251     public BigInteger period() {
   254     public BigInteger period() {
   252         return PERIOD;
   255         return PERIOD;
   253     }
   256     }