From adc93f6097615f16d57e8a24a256302f2144ec4e Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 14 Jan 2005 17:37:50 +0000 Subject: cut out the html - they're going to cause diffing problems. --- man/man3/rand.html | 190 ----------------------------------------------------- 1 file changed, 190 deletions(-) delete mode 100644 man/man3/rand.html (limited to 'man/man3/rand.html') diff --git a/man/man3/rand.html b/man/man3/rand.html deleted file mode 100644 index 0601c6bf..00000000 --- a/man/man3/rand.html +++ /dev/null @@ -1,190 +0,0 @@ - -rand(3) - Plan 9 from User Space - - - - -
-
-
RAND(3)RAND(3) -
-
-

NAME
- -
- - rand, lrand, frand, nrand, lnrand, srand, truerand, ntruerand, - fastrand, nfastrand – 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) -
-
- ulong    truerand(void) -
-
- ulong    ntruerand(ulong val)
- #include <mp.h>
- #include <libsec.h> -
-
- void     genrandom(uchar *buf, int nbytes) -
-
- void     prng(uchar *buf, int nbytes) -
-
- ulong    fastrand(void) -
-
- ulong    nfastrand(ulong val)
-
-
-

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 231 -
- - -
- giving a period of 230 × (2607 – 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. -
- - Truerand returns a random unsigned long read from /dev/random. - Due to the nature of /dev/random, truerand can only return a few - hundred bits a second. -
- - Ntruerand returns a uniform random integer x, 0≤x<val232-1. -
-
- Genrandom fills a buffer with bytes from the X9.17 pseudo-random - number generator. The X9.17 generator is seeded by 24 truly random - bytes read from /dev/random. -
- - Prng uses the native rand(3) pseudo-random number generator to - fill the buffer. Used with srand, this function can produce a - reproducible stream of pseudo random numbers useful in testing. - -
- - Both genrandom and prng may be passed to mprand (see mp(3)). -
- - Fastrand uses genrandom to return a uniform unsigned long x, 0≤x<232-1. - -
-
- Nfastrand uses genrandom to return a uniform unsigned long x, - 0≤x<val232-1.
-
-
-

SOURCE
- -
- - /usr/local/plan9/src/lib9
- /usr/local/plan9/src/libsec/port
-
-
-

SEE ALSO
- -
- - mp(3)
- -
-

BUGS
- -
- - Truerand and ntruerand maintain a static file descriptor. -
- - To avoid name conflicts with the underlying system, rand, lrand, - frand, nrand, lnrand, and srand are preprocessor macros defined - as p9rand, p9lrand, and so on; see intro(3).
- -
- -

-
-
- - -
-
-
-Space Glenda -
-
- - -- cgit v1.2.3