Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rand(3C) — Sun WorkShop 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

drand48(3)

random(3)

rand(3C)  —  COMPATIBILITY FUNCTIONS

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 generator with period 232 that returns successive pseudo-random numbers in the range from 0 to RAND_MAX (defined in <stdlib.h>). 

The function srand() uses the argument seed as a seed for a new sequence of pseudo-random numbers to be returned by subsequent 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. 

SEE ALSO

drand48(3), random(3)

NOTES

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

NOTES

The unbundled ANSI C compiler provides ANSI versions of most of the system header files, which are used automatically at compile time. For example, the directive
#include <stdio.h> will use the file provided by this compiler, rather than /usr/include/stdio.h. 
 

Sun Release 4.1  —  Last change: 21 June 1994

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