This note is a small addition to the article Generating pseudo-random numbers using the random STD library . The author omitted one of the useful functions of the QRandomGenerator class in it. The generator implementation is as follows:
QRandomGenerator *rg = QRandomGenerator::global(); for(int i = 0; i < 10; i++) { qDebug() << rg->bounded(1, 10); }
The global() function returns a pointer to a ready-to-run random number generator. An alternative to it is the system () function, which implements the possibilities for generating random numbers embedded in the operating system. The bounded(a, b) function returns a random number from a to b. The following functions are also available to us: generateDouble() - returns one random number from the range from 0 to 1, generate() and generate64() - return a random 32 and 64 bit random number, respectively. All of the listed functions will return a new sequence of numbers each time they are run/called.
In my opinion, such a toolkit is able to cover all the needs of an average programmer for generating random numbers without connecting third-party libraries.