initstate()

initialize state array for generating pseudo-random numbers 

Function


SYNOPSIS

#include <stdlib.h>

char *initstate(unsigned int seed, char *state, int size);


DESCRIPTION

The initstate() function initializes the state array for generating pseudo-random numbers with random(). The initstate() and setstate() functions handle restarting and changing random-number generators. The initstate() function allows a state array, passed in as an argument, to be initialized for future use. The size in bytes of the state array is used by the initstate() function to decide how sophisticated a random-number generator to use; the larger the state array, the more random the numbers. Values for the amount of state information are 8, 32, 64, 128, and 256 bytes. Amounts less than 8 bytes generate an error, while other amounts are rounded down to the nearest known value.

The seed parameter specifies a starting point for the random-number sequence and provides for restarting at the same point. The initstate() function returns a pointer to the previous state information array.

After initialization, a state array can be restarted at a different point in one of two ways:


PARAMETERS

seed 

Specifies an initial seed value.

state 

Points to the array of state information.

size 

Specifies the size of the state information array.


RETURN VALUES

The initstate() function returns a pointer to the previous state information array. On error, a value of zero is returned.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
random(), setstate(), srandom()


PTC MKS Toolkit 10.3 Documentation Build 39.