Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rand(3C) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

drand48(3C)



RAND(3C-SVR4)       RISC/os Reference Manual        RAND(3C-SVR4)



NAME
     rand, srand - simple random-number generator

SYNOPSIS
     #include <stdlib.h>

     int rand (void);

     void srand (unsigned int seed);

DESCRIPTION
     rand uses a multiplicative congruential random-number gen-
     erator with period 2^32 that returns successive pseudo-
     random RAND_MAX (defined in stdlib.h).  numbers in the range
     from 0 to (2^15)-1.

     The function srand uses the argument seed as a seed for a
     new sequence of pseudo-random numbers to be returned by sub-
     sequent calls to the function rand.  If the function srand
     is then called with the same seed value, the sequence of
     pseudo-random numbers will be repeated.  If the function
     rand is called before any calls to srand have been made, the
     same sequence will be generated as when srand is first
     called with a seed value of 1.

NOTES
     The spectral properties of rand are limited.  drand48(3C)
     provides a much better, though more elaborate, random-number
     generator.

SEE ALSO
     drand48(3C).























                        Printed 11/19/92                   Page 1



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026