375 |
|
* may, and typically does, vary across program invocations. |
376 |
|
*/ |
377 |
|
public SplittableRandom() { // emulate defaultGen.split() |
378 |
< |
long s = defaultGen.getAndAdd(2 * GOLDEN_GAMMA); |
378 |
> |
long s = defaultGen.getAndAdd(GOLDEN_GAMMA << 1); |
379 |
|
this.seed = mix64(s); |
380 |
|
this.gamma = mixGamma(s + GOLDEN_GAMMA); |
381 |
|
} |
531 |
|
} |
532 |
|
|
533 |
|
/** |
534 |
+ |
* Generates a pseudorandom number with the indicated number of |
535 |
+ |
* low-order bits. Because this class has no subclasses, this |
536 |
+ |
* method cannot be invoked or overridden. |
537 |
+ |
* |
538 |
+ |
* @param bits random bits |
539 |
+ |
* @return the next pseudorandom value from this random number |
540 |
+ |
* generator's sequence |
541 |
+ |
*/ |
542 |
+ |
protected int next(int bits) { |
543 |
+ |
return nextInt() >>> (32 - bits); |
544 |
+ |
} |
545 |
+ |
|
546 |
+ |
/** |
547 |
|
* Returns a pseudorandom {@code double} value between the specified |
548 |
|
* origin (inclusive) and bound (exclusive). |
549 |
|
* |
792 |
|
* @return a stream of pseudorandom {@code double} values, |
793 |
|
* each with the given origin (inclusive) and bound (exclusive) |
794 |
|
* @throws IllegalArgumentException if {@code streamSize} is |
795 |
< |
* less than zero |
783 |
< |
* @throws IllegalArgumentException if {@code randomNumberOrigin} |
795 |
> |
* less than zero, or {@code randomNumberOrigin} |
796 |
|
* is greater than or equal to {@code randomNumberBound} |
797 |
|
*/ |
798 |
|
public DoubleStream doubles(long streamSize, double randomNumberOrigin, |