drand48 - Online Linux Manual PageSection : 3
Updated : 2023-02-10
Source : Linux man-pages 6.03

NAMEdrand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 − generate uniformly distributed pseudo-random numbers

LIBRARYStandard C library (libc, −lc)

SYNOPSIS#include <stdlib.h>double drand48(void); double erand48(unsigned short xsubi[3]);long lrand48(void); long nrand48(unsigned short xsubi[3]);long mrand48(void); long jrand48(unsigned short xsubi[3]);void srand48(long 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 >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCE

DESCRIPTIONThese 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 >= 0The parameter m = 2^48, hence 48-bit integer arithmetic is performed. Unless lcong48() is called, a and c are given by: a = 0x5DEECE66D c = 0xBThe 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.

ATTRIBUTESFor an explanation of the terms used in this section, see attributes(7). InterfaceAttributeValue drand48(), erand48(), lrand48(), nrand48(), mrand48(), jrand48(), srand48(), seed48(), lcong48() Thread safety MT-Unsafe race:drand48 The above functions record global state information for the random number generator, so they are not thread-safe.

STANDARDSPOSIX.1-2001, POSIX.1-2008, SVr4.

SEE ALSOrand(3), random(3)
0
Johanes Gumabo
Data Size   :   17,960 byte
man-lcong48.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 202,306
Visitor ID   :     :  
Visitor IP   :   3.145.45.223   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.