Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

drand48(3)

random(3)

rand(3V)

RAND(3C)  —  COMPATIBILITY FUNCTIONS

NAME

rand, srand − simple random number generator

SYNOPSIS

srand(seed)
int seed;

rand()

DESCRIPTION

rand() uses a multiplicative congruential random number generator with period 232 to return successive pseudo-random numbers in the range from 0 to 231−1. 

srand() can be called at any time to reset the random-number generator to a random starting point.  The generator is initially seeded with a value of 1. 

NOTE

The spectral properties of rand() leave a great deal to be desired.  drand48(3) and random(3) provide much better, though more elaborate, random-number generators. 

SEE ALSO

drand48(3), random(3), rand(3V)

BUGS

The low bits of the numbers generated are not very random; use the middle bits.  In particular the lowest bit alternates between 0 and 1. 

Sun Release 4.0  —  Last change: 6 October 1987

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