Random Numbers
Random numbers are necessary for many domains, e.g., to test software, to generate cryptographic keys or for computer games. The random number facility of C++ consists of two components. There is the generation of the random numbers, and there is the distribution of these random numbers. Both components need the header <random>
.
Random number generator
The random number generator generates a random number stream between a minimum and maximum value. This stream is initialized by a “so-called” seed, guaranteeing different sequences of random numbers.
A random number generator gen
of type Generator
supports four different requests:
Generator::result_type
- Data type of the generated random number.
gen()
- Returns a random number.
gen.min()
- Returns the minimum random number that can be returned by
gen()
. gen.max()
- Returns the maximum random number...