class Poco::Random
Overview
A better random number generator. Moreā¦
#include <Random.h> class Random { public: // enums enum Type; // construction Random(int stateSize = 256); // methods void seed(UInt32 seed); void seed(); UInt32 next(); UInt32 next(UInt32 n); char nextChar(); bool nextBool(); float nextFloat(); double nextDouble(); protected: // methods void initState( UInt32 seed, char* arg_state, Int32 n ); static UInt32 goodRand(Int32 x); };
Detailed Documentation
A better random number generator.
Random implements a pseudo random number generator (PRNG). The PRNG is a nonlinear additive feedback random number generator using 256 bytes of state information and a period of up to 2^69.
Construction
Random(int stateSize = 256)
Creates and initializes the PRNG.
Specify either a state buffer size (8 to 256 bytes) or one of the Type values.
Methods
void seed(UInt32 seed)
Seeds the pseudo random generator with the given seed.
void seed()
Seeds the pseudo random generator with a random seed obtained from a RandomInputStream.
UInt32 next()
Returns the next 31-bit pseudo random number.
UInt32 next(UInt32 n)
Returns the next 31-bit pseudo random number modulo n.
char nextChar()
Returns the next pseudo random character.
bool nextBool()
Returns the next boolean pseudo random value.
float nextFloat()
Returns the next float pseudo random number between 0.0 and 1.0.
double nextDouble()
Returns the next double pseudo random number between 0.0 and 1.0.