]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/2/rand
merge
[plan9front.git] / sys / man / 2 / rand
index aba8a8b9c0cf39d47c7729a8aa7d8f62392a91ec..d0a7b4f21cc04c2144775de369df5faedb9c87ad 100644 (file)
@@ -31,8 +31,6 @@ ulong truerand(void)
 .B
 ulong  ntruerand(ulong val)
 .sp
-.B #include <mp.h>
-.br
 .B #include <libsec.h>
 .PP
 .B
@@ -51,13 +49,15 @@ ulong       nfastrand(ulong val)
 returns a uniform pseudo-random
 number
 .IR x ,
-.RI 0≤ x <2\u\s715\s10\d.
+.if t 0≤ \fIx\fR <2\u\s715\s10\d.
+.if n 0≤ x <2^15.
 .PP
 .I Lrand
 returns a uniform
 .B long
 .IR x ,
-.RI 0≤ x <2\u\s731\s10\d.
+.if t 0≤ \fIx\fR <2\u\s731\s10\d.
+.if n 0≤ x <2^31.
 .PP
 .I Frand
 returns a uniform
@@ -107,21 +107,17 @@ starting state.
 .I Truerand
 returns a random unsigned long read from
 .BR /dev/random .
-Due to the nature of
-.BR /dev/random ,
-truerand can only return a few hundred bits a
-second.
 .PP
 .I Ntruerand
 returns a uniform random integer
 .IR x ,
-.RI 0≤ x < val ≤ 2\u\s732\s10\d-1.
+.if t 0≤ \fIx\fR < \fIval\fR ≤ 2\u\s732\s10\d-1.
+.if n 0≤ x < val ≤ 2^32-1.
 .PP
 .I 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
-.BR /dev/random .
+fills a buffer with bytes from the cryptographic pseudo-random
+number generator. The generator is automatically seeded by
+.IR truerand .
 .PP
 .I Prng
 uses the native
@@ -146,7 +142,8 @@ uses
 to return a uniform
 .B "unsigned long
 .IR x ,
-.RI 0≤ x < 2\u\s732\s10\d-1.
+.if t 0≤ \fIx\fR <2\u\s732\s10\d-1.
+.if n 0≤ x <2^32-1.
 .PP
 .I Nfastrand
 uses
@@ -154,7 +151,8 @@ uses
 to return a uniform
 .B "unsigned long
 .IR x ,
-.RI 0≤ x < val ≤ 2\u\s732\s10\d-1.
+.if t 0≤ \fIx\fR < \fIval\fR ≤ 2\u\s732\s10\d-1.
+.if n 0≤ x < val ≤ 2^32-1.
 .SH SOURCE
 .B /sys/src/libc/port/*rand.c
 .br