plan9 man page for rand

Query: rand

OS: plan9

Section: 2

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

RAND(2) 							System Calls Manual							   RAND(2)

NAME
rand, lrand, frand, nrand, lnrand, srand - random number generator
SYNOPSIS
#include <u.h> #include <libc.h> int rand(void) long lrand(void) double frand(void) int nrand(int val) long lnrand(long val) void srand(long seed)
DESCRIPTION
Rand returns a uniform pseudo-random number x, 0<=x<215. Lrand returns a uniform long x, 0<=x<231. Frand returns a uniform double x, 0.0<=x<1.0, This function calls lrand twice to generate a number with as many as 62 significant bits of mantissa. Nrand returns a uniform integer x, 0<=x<val. Lnrand is the same, but returns a long. The algorithm is additive feedback with: x[n] = (x[n-273] + x[n-607]) mod 2^31 giving a period of 2^30 x (2^607 - 1). The generators are initialized by calling srand with whatever you like as argument. To get a different starting value each time, srand(time(0)) will work as long as it is not called more often than once per second. Calling srand(1) will initialize the generators to their starting state. Alef There is no rand in Alef.
SOURCE
/sys/src/libc/port/rand.c RAND(2)
Related Man Pages
rand_r(3) - mojave
srand(3) - mojave
rand_r(3) - suse
srand(3) - freebsd
rand_r(3) - freebsd
Similar Topics in the Unix Linux Community
Shell script that runs a random shell script
Get 20% of lines in File randomly
Random letters
Help setting up a bhyve branded zone
Cant log in from external monitor on laptop with broken screen.