Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

random(3)

rand(3)

Name

rand, srand − random number generator

Syntax

#include <stdlib.h>

void srand(seed)
unsigned seed;

rand()

Description

The newer random() should be used in new applications. The rand subroutine remains for compatibility.

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

The generator is reinitialized by calling srand with 1 as argument. It can be set to a random starting point by calling srand with whatever you like as argument.

Environment

For the System V environment, the rand subroutine returns numbers in the range from 0 to 215−1. 

See Also

random(3)

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