...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::rand48
// In header: <boost/random/linear_congruential.hpp> class rand48 { public: // types typedef int32_t result_type; // construct/copy/destruct template<typename T> rand48(T = 1); template<typename It> rand48(It &, It); // public member functions int32_t min() const; int32_t max() const; template<typename T> void seed(T = 1); template<typename It> void seed(It &, It); int32_t operator()(); // public static functions static bool validation(int32_t); static const bool has_fixed_range; static const int32_t min_value; static const int32_t max_value; };
Class rand48
models a pseudo-random number generator . It uses the linear congruential algorithm with the parameters a = 0x5DEECE66D, c = 0xB, m = 2**48. It delivers identical results to the lrand48()
function available on some systems (assuming lcong48 has not been called).
It is only available on systems where uint64_t
is provided as an integral type, so that for example static in-class constants and/or enum definitions with large uint64_t
numbers work.
rand48
public member functionsint32_t min() const;
Returns the smallest value that the generator can produce
int32_t max() const;
Returns the largest value that the generator can produce
template<typename T> void seed(T x0 = 1);
If T is an integral type smaller than int46_t, changes the current value x(n) of the generator to (x0 << 16) | 0x330e. Otherwise changes the current value x(n) to x0.
template<typename It> void seed(It & first, It last);
int32_t operator()();
Returns the next value of the generator.