Annotation of researchv10dc/man/adm/man3/rand.3, revision 1.1.1.1

1.1       root        1: .TH RAND 3
                      2: .CT 2 math
                      3: .SH NAME
                      4: rand, lrand, frand, nrand, srand \(mi random number generator
                      5: .SH SYNOPSIS
                      6: .nf
                      7: .B int rand()
                      8: .PP
                      9: .B long lrand()
                     10: .PP
                     11: .B double frand()
                     12: .PP
                     13: .B int nrand(val)
                     14: .B int val;
                     15: .PP
                     16: .B srand(seed)
                     17: .B int seed;
                     18: .fi
                     19: .SH DESCRIPTION
                     20: .I Rand
                     21: uses a linear feedback
                     22: random number generator
                     23: to return uniform pseudo-random
                     24: numbers
                     25: .I x,
                     26: .if t .RI 0\(<= x <2\u\s715\s10\d,
                     27: .if n 0<=x<2^15,
                     28: with period about
                     29: .if t 2\u\s732\s0\d.
                     30: .if n 2^32.
                     31: .PP
                     32: .I Lrand
                     33: returns a uniform long
                     34: .I x,
                     35: .if t .RI 0\(<= x <2\u\s731\s10\d,
                     36: .if n 0<=x<2^31,
                     37: with period about
                     38: .if t 2\u\s748\s0\d.
                     39: .if n 2^48.
                     40: .PP
                     41: .I Frand
                     42: returns a uniform double
                     43: .I x,
                     44: .if t .RI 0.0\(<= x <1.0,
                     45: .if n 0.0<=x<1.0,
                     46: always a multiple of
                     47: .if t 2\u\s7\-31\s0\d.
                     48: .if n 2^-31.
                     49: .PP
                     50: .I Nrand
                     51: returns a uniform integer
                     52: .I x,
                     53: .if t .RI 0\(<= x < val.
                     54: .if n 0<=x<val.
                     55: .PP
                     56: The generators are initialized by calling
                     57: .I srand
                     58: with whatever you like as argument.
                     59: To get a different starting value each time,
                     60: .IP
                     61: .L
                     62: srand((int)time((long *)0));
                     63: .LP
                     64: will work as long as it is not called more often
                     65: than once per second.
                     66: .SH BUGS
                     67: .I Rand
                     68: and
                     69: .I lrand
                     70: are quite machine-dependent.
                     71: Although
                     72: .I frand
                     73: and
                     74: .I nrand
                     75: are more portable, they appear in few versions of Unix.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.