summaryrefslogtreecommitdiff
path: root/usr/src/man/man3ucb/rand.3ucb
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/man/man3ucb/rand.3ucb')
-rw-r--r--usr/src/man/man3ucb/rand.3ucb51
1 files changed, 51 insertions, 0 deletions
diff --git a/usr/src/man/man3ucb/rand.3ucb b/usr/src/man/man3ucb/rand.3ucb
new file mode 100644
index 0000000000..be78f1351e
--- /dev/null
+++ b/usr/src/man/man3ucb/rand.3ucb
@@ -0,0 +1,51 @@
+'\" te
+.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
+.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH rand 3UCB "30 Oct 2007" "SunOS 5.11" "SunOS/BSD Compatibility Library Functions"
+.SH NAME
+rand, srand \- simple random number generator
+.SH SYNOPSIS
+.LP
+.nf
+\fB/usr/ucb/cc\fR [ \fIflag\fR ... ] \fIfile\fR ...
+
+int \fBrand\fR();
+.fi
+
+.LP
+.nf
+\fBint\fR \fBsrand\fR(\fIseed\fR)
+\fBunsigned\fR \fIseed\fR;
+.fi
+
+.SH DESCRIPTION
+.sp
+.LP
+\fBrand()\fR uses a multiplicative congruential random number generator with
+period 2^32 to return successive pseudo-random numbers in the range from 0 to
+2^31 \(mi\|1.
+.sp
+.LP
+\fBsrand()\fR can be called at any time to reset the random-number generator to
+a random starting point. The generator is initially seeded with a value of 1.
+.SH SEE ALSO
+.sp
+.LP
+\fBdrand48\fR(3C), \fBrand\fR(3C), \fBrandom\fR(3C)
+.SH NOTES
+.sp
+.LP
+Use of these interfaces should be restricted to only applications written on
+BSD platforms. Use of these interfaces with any of the system libraries or in
+multi-thread applications is unsupported.
+.sp
+.LP
+The spectral properties of \fBrand()\fR leave a great deal to be desired.
+\fBdrand48\fR(3C) and \fBrandom\fR(3C) provide much better, though more
+elaborate, random-number generators.
+.sp
+.LP
+The low bits of the numbers generated are not very random; use the middle bits.
+In particular the lowest bit alternates between 0 and 1.