MCPcopy Create free account
hub / github.com/ReadyTalk/avian / nextInt

Method nextInt

classpath/java/util/Random.java:45–63  ·  view source on GitHub ↗
(int limit)

Source from the content-addressed store, hash-verified

43 }
44
45 public int nextInt(int limit) {
46 if (limit <= 0) {
47 throw new IllegalArgumentException();
48 }
49
50 if ((limit & -limit) == limit) {
51 // limit is a power of two
52 return (int) ((limit * (long) next(31)) >> 31);
53 }
54
55 int bits;
56 int value;
57 do {
58 bits = next(31);
59 value = bits % limit;
60 } while (bits - value + (limit - 1) < 0);
61
62 return value;
63 }
64
65 public int nextInt() {
66 return next(32);

Callers 2

nextBytesMethod · 0.95
shuffleMethod · 0.80

Calls 1

nextMethod · 0.95

Tested by

no test coverage detected