NAME
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 - generate uniformly distributed pseudo-random numbers
SYNOPSIS
#include <stdlib.h> double drand48(void); double erand48(unsigned short xsubi[3]); long int lrand48(void); long int nrand48(unsigned short xsubi[3]); long int mrand48(void); long int jrand48(unsigned short xsubi[3]); void srand48(long int seedval); unsigned short *seed48(unsigned short seed16v[3]); void lcong48(unsigned short param[7]); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): All functions shown above: _XOPEN_SOURCE || /* Glibc since 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _SVID_SOURCE
DESCRIPTION
These functions generate pseudo-random numbers using the linear congruential algorithm and 48-bit integer arithmetic. The drand48() and erand48() functions return nonnegative double- precision floating-point values uniformly distributed over the interval [0.0, 1.0). The lrand48() and nrand48() functions return nonnegative long integers uniformly distributed over the interval [0, 2^31). The mrand48() and jrand48() functions return signed long integers uniformly distributed over the interval [-2^31, 2^31). The srand48(), seed48() and lcong48() functions are initialization functions, one of which should be called before using drand48(), lrand48() or mrand48(). The functions erand48(), nrand48() and jrand48() do not require an initialization function to be called first. All the functions work by generating a sequence of 48-bit integers, Xi, according to the linear congruential formula: Xn+1 = (aXn + c) mod m, where n >= 0 The parameter m = 2^48, hence 48-bit integer arithmetic is performed. Unless lcong48() is called, a and c are given by: a = 0x5DEECE66D c = 0xB The value returned by any of the functions drand48(), erand48(), lrand48(), nrand48(), mrand48() or jrand48() is computed by first generating the next 48-bit Xi in the sequence. Then the appropriate number of bits, according to the type of data item to be returned, is copied from the high-order bits of Xi and transformed into the returned value. The functions drand48(), lrand48() and mrand48() store the last 48-bit Xi generated in an internal buffer. The functions erand48(), nrand48() and jrand48() require the calling program to provide storage for the successive Xi values in the array argument xsubi. The functions are initialized by placing the initial value of Xi into the array before calling the function for the first time. The initializer function srand48() sets the high order 32-bits of Xi to the argument seedval. The low order 16-bits are set to the arbitrary value 0x330E. The initializer function seed48() sets the value of Xi to the 48-bit value specified in the array argument seed16v. The previous value of Xi is copied into an internal buffer and a pointer to this buffer is returned by seed48(). The initialization function lcong48() allows the user to specify initial values for Xi, a and c. Array argument elements param[0-2] specify Xi, param[3-5] specify a, and param[6] specifies c. After lcong48() has been called, a subsequent call to either srand48() or seed48() will restore the standard values of a and c.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). ┌──────────────────────┬───────────────┬────────────────────────┐ │Interface │ Attribute │ Value │ ├──────────────────────┼───────────────┼────────────────────────┤ │drand48(), erand48(), │ Thread safety │ MT-Unsafe race:drand48 │ │lrand48(), nrand48(), │ │ │ │mrand48(), jrand48(), │ │ │ │srand48(), seed48(), │ │ │ │lcong48() │ │ │ └──────────────────────┴───────────────┴────────────────────────┘ The above functions record global state information for the random number generator, so they are not thread-safe.
CONFORMING TO
POSIX.1-2001, POSIX.1-2008, SVr4.
SEE ALSO
rand(3), random(3)
COLOPHON
This page is part of release 4.09 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2016-03-15 DRAND48(3)
More Linux Commands
manpages/XDrawPoint.3.html
XDrawPoint(3) - draw points and points structure (Man Page)
The XDrawPoint function uses the foreground pixel and function components of the GC to draw a single point into the specified drawable; XDrawPoints draws multip
manpages/nlmconv.1.html
nlmconv(1) - converts object code into an NLM. (Man Page)...
nlmconv converts the relocatable i386 object file infile into the NetWare Loadable Module outfile, optionally reading headerfile for NLM header information. For
manpages/getrpcbynumber_r.3.html
getrpcbynumber_r(3) - get RPC entry (reentrant) (Man Page)
The getrpcent_r(), getrpcbyname_r(), and getrpcbynumber_r() functions are the reentrant equivalents of, respectively, getrpcent(3), getrpcbyname(3), and getrpcb
manpages/systemd-timedated.8.html
systemd-timedated(8) Time and date bus mechanism (Man Page)
systemd-timedated is a system service that may be used as a mechanism to change the system clock and timezone, as well as to enable/disable NTP time synchroniza
manpages/autotrace.1.html
autotrace(1) converts bitmap image data into vector graphics
The autotrace program accepts bitmap graphics from the file inputfile specified on the command line, and as output produces a collection of splines approximatin
manpages/XGetModifierMapping.3.html
XGetModifierMapping(3) - manipulate keyboard encoding and ke
The XChangeKeyboardMapping function defines the symbols for the specified number of KeyCodes starting with first_keycode. The symbols for KeyCodes outside this
manpages/Tcl_CreateEncoding.3.html
Tcl_CreateEncoding(3) - procedures for creating and using en
Tcl_GetEncoding finds an encoding given its name. The name may refer to a built-in Tcl encoding, a user-defined encoding registered by calling Tcl_CreateEncodin
manpages/ppmtoppm.1.html
ppmtoppm(1) - copy PPM image (Commands - Linux man page)....
This program is part of Netpbm(1) ppmtoppm simply copies a PPM image from Standard Input to Standard Output. This may seem an unnecessary duplication of cat, bu
manpages/btrfs-balance.8.html
btrfs-balance(8) balance btrfs filesystem - Linux man page
btrfs balance is used to balance chunks in a btrfs filesystem across multiple or even single device. See btrfs-device(8) for more details about the effect on de
manpages/Tcl_SignalId.3.html
Tcl_SignalId(3) - Convert signal codes - Linux manual page
Tcl_SignalId and Tcl_SignalMsg return a string representation of the provided signal number (sig). Tcl_SignalId returns a machine-readable textual identifier su
manpages/ldap_value_free.3.html
ldap_value_free(3) - LDAP attribute value handling routines
These routines are used to retrieve and manipulate attribute values from an LDAP entry as returned by ldap_first_entry(3) or ldap_next_entry(3). ldap_get_values
manpages/DMXGetDesktopAttributes.3.html
DMXGetDesktopAttributes(3) - determine global bounding box
DMXGetDesktopAttributes() returns information about the desktop in DMXDesktopAttributes: typedef struct { unsigned int width; unsigned int height; int shiftX; i
