Random integers
Back to The seed. Forward to Random real numbers. Up to Contents.

The following routines return random integers of the given type uniformly distributed in [min, max]. These are member functions of Random.

Definitions of routines returning integers
routine type min max
Integer<IntType, b>() IntType 0 2b - 1
Integer<b>() unsigned 0 2b - 1
Integer(); unsigned 0 std::numeric_limits<unsigned>::max()
Integer<IntType>() IntType std::numeric_limits<IntType>::min() std::numeric_limits<IntType>::max()
Boolean() bool false true
Integer<IntType>(IntType n) IntType 0 n - 1
(if n == 0, std::numeric_limits<IntType>::max();
if n < 0, 0)
IntegerC<IntType>(IntType n) IntType 0 n
(if n < 0, 0)
IntegerC<IntType>(IntType m, IntType n) IntType m n
(if n < m, m)
operator()() Random::result_type 0 2w - 1
operator()(result_type n) Random::result_type 0 n - 1
(if n == 0, std::numeric_limits<result_type>::max())

Here w = Random::width. For the default random generator, result_type is an unsigned int and w = 32.

Back to The seed. Forward to Random real numbers. Up to Contents.