'\"macro stdmacro
.if n .pH g3c.rand @(#)rand	40.8 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} rand 3C "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} rand 3C "C Programming Language Utilities"
.if \nX=2 .ds x} rand 3C "" "\&"
.if \nX=3 .ds x} rand "" "" "\&"
.TH \*(x}
.SH NAME
\f4rand\f1, \f4srand\f1 \- simple random-number generator
.SH SYNOPSIS
\f4#include <stdlib.h>\f1
.PP
\f4int rand (void);\f1
.PP
\f4void srand (unsigned int seed);\f1
.SH DESCRIPTION
\f4rand\fP
uses a multiplicative congruential
random-number generator
.if t with period 2\u\s-232\s0\d
.if n with period 2^32
that returns successive pseudo-random
.if t numbers in the range from 0 to \f4RAND_MAX\fP (defined in \f4stdlib.h\fP).
.if n numbers in the range from 0 to (2^15)-1.
.PP
The function \f4srand\f1 uses the argument \f2seed\fP as a seed for a new
sequence of pseudo-random numbers to be returned by subsequent calls to the
function \f4rand\f1.
If the function \f4srand\f1 is then called with the same \f2seed\fP value, the
sequence of pseudo-random numbers will be repeated.
If the function \f4rand\f1 is called before any calls to
\f4srand\f1 have been made, the same sequence will be generated as when
\f4srand\f1 is first called with a \f2seed\fP value of 1. 
.SH NOTES
The spectral properties of
\f4rand\fP
are limited.
\f4drand48\fP(3C)
provides a much better, though more elaborate, random-number generator.
.SH SEE ALSO
\f4drand48\fP(3C).
.\"	@(#)rand.3c	6.2 of 10/20/83
.Ee
