Pseudorandom number generators
Various implementations of pseudorandom number generators (PRNG). The return value is always a number between 0.0 and 1.0.
PRN calculation by using Xorshift (32bit) algorithm
A PRN between 0.0 and 1.0 is calculated using the Xorshift (32bit) algorithm. A static variable contains the starting value for the Xorshift. If no (re)initialisation should be performed, the calculation result of the last function call is used as new starting value when calling the function again (static variable). The initialisation value should be a true random number.
PRN calculation by using rnd algorithm of VB6
A PRN between 0.0 and 1.0 is calculated using the rnd algorithm of VB6. A static variable contains the starting value. If no (re)initialisation should be performed, the calculation result of the last function call is used as new starting value when calling the function again (static variable). The initialisation value should be a true random number.
PRN calculation by using Multiply-with-carry algorithm
A PRN between 0.0 and 1.0 is calculated using George Marsaglia's MWC algorithm to produce an unsigned integer. Two static variables that contain the seeds are separately used within the algorithm and the output results directly from them. The two partial results are used as initial values when calling the function again (static variables). The initialisation value of one seed should be a true random number.
PRN calculation by using CRC32 algorithm
A PRN between 0.0 and 1.0 is calculated using the CRC32 algorithm. A static variable contains the starting value for the CRC32. If no (re)initialisation should be performed, the calculation result of the last function call is used as new starting value when calling the function again (static variable). The system function CRC32() requires an array of s32 values (cells) as parameter input hence the initialisation value needs to be a s32 type cell array. The initialisation value should be a true random number.