- Kernel class Random (not visible in AOT). Generates a value in the range [0..32767] by calling nextInt() instance method.
- Class RandomGenerate (which extends Random class). Generates a value in the specified range by calling randomInt() instance method.
- xGlobal::randomPositiveInt32() method. Generates a value in the range [0..2147483647].
Actually, the third way seems to be the most preferable because there is some trick with first two ones. If the new Random class instance will be created each time before calling nextInt(), the output values will be very far from random. For example, the following code:
static void testRandom(Args _args)
for (i = 0; i < 3; i++)
random = new Random();
On the first run will give the following output:
And on the second run: