[Gambas-user] Random Numbers Functions info

Benoît Minisini g4mba5 at gmail.com
Mon May 9 16:26:06 CEST 2022


Le 08/05/2022 à 07:08, Charles Bukowski a écrit :
> Not for any particular reason. I am asking just to understand if 
> randomness level of numbers generated by standard gambas functions is 
> the same/comparable with the analogue rnd functions of more popular 
> programming languages (e.g. c, c++,python,java).
> 

It depends on what your need.

Sometimes what you need is reproducibility, and how much random are the 
pseudo-random numbers is not very important.

Sometimes you need the contrary, usually for cryptographic reasons, and 
you want pseudo-random numbers as much random as possible.

In gambas, you make the difference with the RANDOMIZE instruction that 
intializes the pseudo-random numbers generator.

The same seed gives you the same numbers, so you achieve 
reproducibility. At startup, the seed is initialized with the time of 
the day.

Otherwise, either you directly use what is provided by the OS 
('/dev/random' or '/dev/urandom') for maximum randomness, either you use 
RANDOMIZE with the result of '/dev/(u)random' to get a random number serie.

Regards,

-- 
Benoît Minisini


More information about the User mailing list