Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
Guardian Native C Library Calls (n - r) random(3)
NAME
random - Generates random numbers
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZSTFNSRL
G-series native OSS processes: /G/system/sysnn/zstfnsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCREDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcredll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycredll
SYNOPSIS
#include <stdlib.h>
long random(void);
PARAMETERS
None.
DESCRIPTION
The random() function generates a pseudo-random number in the range 0 (zero) to 2**31-1
using a nonlinear additive feedback random-number generator. By default, this generator uses a
state array size of 31 long integers and has an approximate period of 16*(2**31-1). If the size of
the state array is increased, the period of the random-number generator is increased. For example,
with 256 bytes of state information, the random-number generator would have a period greater
than 2**69.
If you call the random( ) function without a previous call to the initstate() function, it behaves
as though you had called initstate() with seed equal to 1 and size equal to 128.
After you have initialized a state array with the initstate() function, you can use the setstate()
function to switch state arrays. Subsequent calls to the random() function will use the state
array pointed to by the state parameter until either initstate() is called or setstate() is called
again.
NOTES
This function can be called by native processes only.
RETURN VALUES
The random() function returns a pseudo-random number.
ERRORS
None. This function does not set errno.
RELATED INFORMATION
Functions: initstate(3), setstate(3), srandom(3).
STANDARDS CONFORMANCE
The random() function is defined in the XPG4 Version 2 specification.
527192-018 Hewlett-Packard Company 5−85