com.flextrade.jfixture.utility.FixtureMath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfixture Show documentation
Show all versions of jfixture Show documentation
JFixture is an open source library based on the popular .NET library, AutoFixture
package com.flextrade.jfixture.utility;
import java.util.Random;
public class FixtureMath {
private static final Random RND = new Random();
public static long randLong(long min, long max) {
long randomLong = nextLong((max - min) + 1) + min;
return randomLong;
}
// http://stackoverflow.com/a/2546186/255231
public static long nextLong(long n) {
// error checking and 2^x checking removed for simplicity.
long bits, val;
do {
bits = (RND.nextLong() << 1) >>> 1;
val = bits % n;
} while (bits-val+(n-1) < 0L);
return val;
}
}