drand48 (3)
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.delim $$
NAME
drand48, erand48, jrand48, lcong48, lrand48, mrand48, nrand48, seed48, srand48 --- generate uniformly distributed pseudo-random numbersSYNOPSIS
#include <stdlib.h> double drand48(void); double erand48(unsigned short xsubi[3]); long jrand48(unsigned short xsubi[3]); void lcong48(unsigned short param[7]); long lrand48(void); long mrand48(void); long nrand48(unsigned short xsubi[3]); unsigned short *seed48(unsigned short seed16v[3]); void srand48(long seedval);
DESCRIPTION
This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. The drand48() and erand48() functions shall return non-negative, double-precision, floating-point values, uniformly distributed over the interval [0.0,1.0). The lrand48() and nrand48() functions shall return non-negative, long integers, uniformly distributed over the interval [0,231
).
The
mrand48()
and
jrand48()
functions shall return signed long integers uniformly distributed over
the interval [-231
,231
).
The
srand48(),
seed48(),
and
lcong48()
functions are initialization entry points, one of which should be
invoked before either
drand48(),
lrand48(),
or
mrand48()
is called. (Although it is not recommended practice, constant default
initializer values shall be supplied automatically if
drand48(),
lrand48(),
or
mrand48()
is called without a prior call to an initialization entry point.) The
erand48(),
nrand48(),
and
jrand48()
functions do not require an initialization entry point to be called
first.
All the routines work by generating a sequence of 48-bit integer
values, $X_ i" " ,$ according to the linear congruential formula:
- $X sub{n+1} " " = " " (aX_ n" "^+^c) sub{roman mod " " m} " " " " " " " " " " " " " " " " n>= " " 0$
- $a " " mark = " " roman "5DEECE66D"^sub 16 " " = " " roman 273673163155^sub 8$ $c " " lineup = " " roman B^sub 16 " " = " " roman 13^sub 8$
RETURN VALUE
As described in the DESCRIPTION above.ERRORS
No errors are defined.The following sections are informative.
EXAMPLES
None.APPLICATION USAGE
None.RATIONALE
None.FUTURE DIRECTIONS
None.SEE ALSO
rand() The Base Definitions volume of POSIX.1-2008, <stdlib.h>COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at www.unix.org/online.html .Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see www.kernel.org/doc/man-pages/reporting_bugs.html .