File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/main/java/de/tilman_neumann/jml/random Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 13
13
*/
14
14
package de .tilman_neumann .jml .random ;
15
15
16
- import static org .junit .Assert .assertTrue ;
17
-
18
16
import java .util .Random ;
19
17
18
+ import de .tilman_neumann .util .Ensure ;
19
+
20
20
/**
21
21
* 64 bit random number generator using Random.nextLong() and the strategy from Java17 for Random.nextLong(long maxValue).
22
22
*/
23
- public abstract class Random64 {
23
+ public class Random64 {
24
24
25
25
private static final boolean DEBUG = false ;
26
26
@@ -58,10 +58,10 @@ public long nextLong(long maxValue) {
58
58
while (true ) {
59
59
r = u % maxValue ; // now 0 <= r <= u and r < maxValue
60
60
if (DEBUG ) {
61
- assertTrue ( u >= 0 );
62
- assertTrue ( r >= 0 );
63
- assertTrue ( r <= u );
64
- assertTrue ( r < maxValue );
61
+ Ensure . ensureGreaterEquals ( u , 0L );
62
+ Ensure . ensureGreaterEquals ( r , 0 );
63
+ Ensure . ensureSmallerEquals ( r , u );
64
+ Ensure . ensureSmaller ( r , maxValue );
65
65
}
66
66
// Using the modulus r = u % maxValue to obtain random numbers < maxValue has its caveats...
67
67
// If u is close to 2^63, then r much smaller than maxValue are over-represented.
You can’t perform that action at this time.
0 commit comments