Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
setstate(3)
Edit
PageHistory
Diff
Info
LikePages
RANDOM !!!RANDOM NAME SYNOPSIS DESCRIPTION RETURN VALUE ERRORS NOTES CONFORMING TO SEE ALSO ---- !!NAME random, srandom, initstate, setstate - random number generator. !!SYNOPSIS __#include __ ''seed''__); char *initstate(unsigned int__ ''seed''__, char *__''state''__, size_t__ ''n''__); char *setstate(char *__''state''__); __ !!DESCRIPTION The __random()__ function uses a non-linear additive feedback random number generator employing a default table of size 31 long integers to return successive pseudo-random numbers in the range from 0 to __RAND_MAX__. The period of this random number generator is very large, approximately 16*((2**31)-1). The __srandom()__ function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by __random()__. These sequences are repeatable by calling __srandom()__ with the same seed value. If no seed value is provided, the __random()__ function is automatically seeded with a value of 1. The __initstate()__ function allows a state array ''state'' to be initialized for use by __random()__. The size of the state array ''n'' is used by __initstate()__ to decide how sophisticated a random number generator it should use -- the larger the state array, the better the random numbers will be. ''seed'' is the seed for the initialization, which specifies a starting point for the random number sequence, and provides for restarting at the same point. The __setstate()__ function changes the state array used by the __random()__ function. The state array ''state'' is used for random number generation until the next call to __initstate()__ or __setstate()__. ''state'' must first have been initialized using __initstate()__ or be the result of a previous call of __setstate()__. !!RETURN VALUE The __random()__ function returns a value between 0 and RAND_MAX. The __srandom()__ function returns no value. The __initstate()__ and __setstate()__ functions return a pointer to the previous state array, or NULL on error. !!ERRORS __EINVAL__ A state array of less than 8 bytes was specified to __initstate()__. !!NOTES Current n'' are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the nearest known amount. Using less than 8 bytes will cause an error. !!CONFORMING TO BSD 4.3 !!SEE ALSO rand(3), srand(3) ----
3 pages link to
setstate(3)
:
Man3s
rand(3)
srand(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.