aboutsummaryrefslogtreecommitdiffstats
path: root/man3/rand.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/rand.3')
-rw-r--r--man3/rand.350
1 files changed, 25 insertions, 25 deletions
diff --git a/man3/rand.3 b/man3/rand.3
index ef27552fbd..5c1ef04fa5 100644
--- a/man3/rand.3
+++ b/man3/rand.3
@@ -96,26 +96,15 @@ between 0 and RAND_MAX.
The
.BR srand ()
function returns no value.
-.SH EXAMPLE
-POSIX.1-2001 gives the following example of an implementation of
+.SH "CONFORMING TO"
+The functions
.BR rand ()
and
-.BR srand (),
-possibly useful when one needs the same sequence on two different machines.
-.sp
-.nf
- static unsigned long next = 1;
-
- /* RAND_MAX assumed to be 32767 */
- int myrand(void) {
- next = next * 1103515245 + 12345;
- return((unsigned)(next/65536) % 32768);
- }
-
- void mysrand(unsigned seed) {
- next = seed;
- }
-.fi
+.BR srand ()
+conform to SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
+The function
+.BR rand_r ()
+is from POSIX.1-2001.
.SH NOTES
The versions of
.BR rand ()
@@ -169,15 +158,26 @@ in depth, see Chapter 3 (Random Numbers) in Donald E. Knuth's
.IR "The Art of Computer Programming" ,
volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts:
Addison-Wesley Publishing Company, 1981.
-.SH "CONFORMING TO"
-The functions
+.SH EXAMPLE
+POSIX.1-2001 gives the following example of an implementation of
.BR rand ()
and
-.BR srand ()
-conform to SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
-The function
-.BR rand_r ()
-is from POSIX.1-2001.
+.BR srand (),
+possibly useful when one needs the same sequence on two different machines.
+.sp
+.nf
+ static unsigned long next = 1;
+
+ /* RAND_MAX assumed to be 32767 */
+ int myrand(void) {
+ next = next * 1103515245 + 12345;
+ return((unsigned)(next/65536) % 32768);
+ }
+
+ void mysrand(unsigned seed) {
+ next = seed;
+ }
+.fi
.SH "SEE ALSO"
.BR drand48 (3),
.BR random (3)