Lines Matching refs:bound

174      * origin is greater than bound, acts as unbounded form of
177 * @param origin the least value, unless greater than bound
178 * @param bound the upper bound (exclusive), must not equal origin
181 final long internalNextLong(long origin, long bound) {
183 if (origin < bound) {
184 long n = bound - origin, m = n - 1;
195 while (r < origin || r >= bound)
206 * @param origin the least value, unless greater than bound
207 * @param bound the upper bound (exclusive), must not equal origin
210 final int internalNextInt(int origin, int bound) {
212 if (origin < bound) {
213 int n = bound - origin, m = n - 1;
224 while (r < origin || r >= bound)
234 * @param origin the least value, unless greater than bound
235 * @param bound the upper bound (exclusive), must not equal origin
238 final double internalNextDouble(double origin, double bound) {
240 if (origin < bound) {
241 r = r * (bound - origin) + origin;
242 if (r >= bound) // correct for rounding
243 r = Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1);
259 * and the specified bound (exclusive).
261 * @param bound the upper bound (exclusive). Must be positive.
263 * (inclusive) and the bound (exclusive)
264 * @throws IllegalArgumentException if {@code bound} is not positive
266 public int nextInt(int bound) {
267 if (bound <= 0)
270 int m = bound - 1;
271 if ((bound & m) == 0) // power of two
275 u + m - (r = u % bound) < 0;
284 * origin (inclusive) and the specified bound (exclusive).
287 * @param bound the upper bound (exclusive)
289 * (inclusive) and the bound (exclusive)
291 * or equal to {@code bound}
293 public int nextInt(int origin, int bound) {
294 if (origin >= bound)
296 return internalNextInt(origin, bound);
310 * and the specified bound (exclusive).
312 * @param bound the upper bound (exclusive). Must be positive.
314 * (inclusive) and the bound (exclusive)
315 * @throws IllegalArgumentException if {@code bound} is not positive
317 public long nextLong(long bound) {
318 if (bound <= 0)
321 long m = bound - 1;
322 if ((bound & m) == 0L) // power of two
326 u + m - (r = u % bound) < 0L;
335 * origin (inclusive) and the specified bound (exclusive).
338 * @param bound the upper bound (exclusive)
340 * (inclusive) and the bound (exclusive)
342 * or equal to {@code bound}
344 public long nextLong(long origin, long bound) {
345 if (origin >= bound)
347 return internalNextLong(origin, bound);
363 * (inclusive) and the specified bound (exclusive).
365 * @param bound the upper bound (exclusive). Must be positive.
367 * (inclusive) and the bound (exclusive)
368 * @throws IllegalArgumentException if {@code bound} is not positive
370 public double nextDouble(double bound) {
371 if (!(bound > 0.0))
373 double result = (mix64(nextSeed()) >>> 11) * DOUBLE_UNIT * bound;
374 return (result < bound) ? result : // correct for rounding
375 Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1);
380 * origin (inclusive) and bound (exclusive).
383 * @param bound the upper bound (exclusive)
385 * (inclusive) and the bound (exclusive)
387 * or equal to {@code bound}
389 public double nextDouble(double origin, double bound) {
390 if (!(origin < bound))
392 return internalNextDouble(origin, bound);
474 * origin (inclusive) and bound (exclusive).
478 * @param randomNumberBound the bound (exclusive) of each random value
480 * each with the given origin (inclusive) and bound (exclusive)
500 * int} values, each conforming to the given origin (inclusive) and bound
507 * @param randomNumberBound the bound (exclusive) of each random value
509 * each with the given origin (inclusive) and bound (exclusive)
562 * (inclusive) and bound (exclusive).
566 * @param randomNumberBound the bound (exclusive) of each random value
568 * each with the given origin (inclusive) and bound (exclusive)
588 * long} values, each conforming to the given origin (inclusive) and bound
595 * @param randomNumberBound the bound (exclusive) of each random value
597 * each with the given origin (inclusive) and bound (exclusive)
652 * (inclusive) and bound (exclusive).
656 * @param randomNumberBound the bound (exclusive) of each random value
658 * each with the given origin (inclusive) and bound (exclusive)
679 * double} values, each conforming to the given origin (inclusive) and bound
686 * @param randomNumberBound the bound (exclusive) of each random value
688 * each with the given origin (inclusive) and bound (exclusive)
704 * versions into one class by treating a bound less than origin as
715 final int bound;
717 int origin, int bound) {
719 this.origin = origin; this.bound = bound;
725 new RandomIntsSpliterator(i, index = m, origin, bound);
741 consumer.accept(ThreadLocalRandom.current().internalNextInt(origin, bound));
753 int o = origin, b = bound;
770 final long bound;
772 long origin, long bound) {
774 this.origin = origin; this.bound = bound;
780 new RandomLongsSpliterator(i, index = m, origin, bound);
796 consumer.accept(ThreadLocalRandom.current().internalNextLong(origin, bound));
808 long o = origin, b = bound;
826 final double bound;
828 double origin, double bound) {
830 this.origin = origin; this.bound = bound;
836 new RandomDoublesSpliterator(i, index = m, origin, bound);
852 consumer.accept(ThreadLocalRandom.current().internalNextDouble(origin, bound));
864 double o = origin, b = bound;
990 static final String BAD_BOUND = "bound must be positive";
991 static final String BAD_RANGE = "bound must be greater than origin";