I am implementing a test data generator in java that uses to generate random values for java primitive types. The range of possible parameters values is not limited. For example, if I want to generate a random integer or float I will consider all possible values (MAX_INT-MIN_INT). To do so, I am using stuff like :
- Random().nextInt()
- Random().nextLong()
- Random().nextFloat()*Float.MAX_VALUE
- Random().nextDouble()*Double.MAX_VALUE
- And so on...
However, doing like this, I note that the generated values are always high (close to the max and low value of the parameter type). After 100000 iteration for example, the random operator didn't generate a value in the range [-1000 - 1000]. The same thing for floats, longs. etc,...
Can you give me an explanation of how the random operator is performing in Java? Why the generated values are always high when we consider all possible values of the Java type?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire