3.3 KiB
[rand.general]
29 Numerics library [numerics]
29.5 Random number generation [rand]
29.5.1 General [rand.general]
Subclause [rand] defines a facility for generating (pseudo-)random numbers.
In addition to a few utilities, four categories of entities are described:uniform random bit generators,random number engines,random number engine adaptors, andrandom number distributions.
These categorizations are applicable to types that meet the corresponding requirements, to objects instantiated from such types, and to templates producing such types when instantiated.
[Note 1:
These entities are specified in such a way as to permit the binding of any uniform random bit generator object e as the argument to any random number distribution object d, thus producing a zero-argument function object such as given by bind(d,e).
â end note]
Each of the entities specified in [rand] has an associated arithmetic type ([basic.fundamental]) identified as result_type.
With T as the result_type thus associated with such an entity, that entity is characterized:
as boolean or equivalently as boolean-valued, if T is bool;
otherwise as integral or equivalently as integer-valued, if numeric_limits::is_integer is true;
otherwise as floating-point or equivalently as real-valued.
If integer-valued, an entity may optionally be further characterized assigned or unsigned, according to numeric_limits::is_signed.
Unless otherwise specified, all descriptions of calculations in [rand] use mathematical real numbers.
Throughout [rand], the operatorsbitand, bitor, and xor denote the respective conventional bitwise operations.
Further:
the operator rshift denotes a bitwise right shift with zero-valued bits appearing in the high bits of the result, and
the operator lshiftw denotes a bitwise left shift with zero-valued bits appearing in the low bits of the result, and whose result is always taken modulo 2w.