Package de.tilman_neumann.jml.base
Class Rng
- java.lang.Object
-
- java.util.Random
-
- de.tilman_neumann.jml.base.Rng
-
- All Implemented Interfaces:
Serializable
public class Rng extends Random
Simple helper class to generate random numbers.- Author:
- Tilman Neumann
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rng()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
nextInt(int min, int max)
Creates a random integer from the uniform distribution U[min, max-1].long
nextLong(long max)
Creates a random long from the uniform distribution U[0, max-1].long
nextLong(long min, long max)
Creates a random long from the uniform distribution U[min, max-1].
-
-
-
Method Detail
-
nextInt
public int nextInt(int min, int max)
Creates a random integer from the uniform distribution U[min, max-1]. The only requirements are min >= 0 and max > min.- Parameters:
min
-max
-- Returns:
- random int in the desired range
-
nextLong
public long nextLong(long max)
Creates a random long from the uniform distribution U[0, max-1]. The only requirement is max > 0.- Parameters:
max
-- Returns:
- random long in the desired range
-
nextLong
public long nextLong(long min, long max)
Creates a random long from the uniform distribution U[min, max-1]. The only requirements are min >= 0 and max > min.- Parameters:
min
-max
-- Returns:
- random long in the desired range
-
-