<- Click here to Toggle

Home » Resources » Random Constraints » Random System Functions & Methods

Random System Functions & Methods

$urandom:

The system function $urandom provides a mechanism for generating pseudorandom numbers. The function returns a new 32-bit random number each time it is called. The number shall be unsigned. The syntax for $urandom is:

function int unsigned $urandom [ (int seed ) ] ;

$urandom_range():

The $urandom_range() function returns an unsigned integer within a specified range.The syntax for $urandom_range() is:

function int unsigned $urandom_range( int unsigned maxval, int unsigned minval = 0 );

srandom():

The srandom() method allows manually seeding the Random Number Generator (RNG) of objects or threads.

get_randstate():

The get_randstate() method retrieves the current state an object’s Random Number Generator (RNG).

The state of the RNG associated with a process is retrieved using the get_randstate() method of the process

The prototype of the get_randstate() method is:

function string get_randstate();

get_randstate():

The get_randstate() method retrieves the current state an object’s Random Number Generator (RNG). The state of the RNG associated with a process is retrieved using the get_randstate() method of the process

The prototype of the get_randstate() method is:

function string get_randstate();

set_randstate():

The set_randstate() method sets the state of an object’s Random Number Generator (RNG). The state of the RNG associated with a process is set using the set_randstate() method of the process.

prototype of the set_randstate() method is:

function void set_randstate( string state );

Random stability:

The Random Number Generator (RNG) is localized to threads and objects. Because the sequence of random values returned by a thread or object is independent of the RNG in other threads or objects, this property is called random stability. Random stability applies to:

The system randomization calls, $urandom() and $urandom_range().