Penguin
Annotated edit history of drand48(3) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 JohnMcPherson 2 drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 - generate uniformly distributed pseudo-random numbers
1 perry 3
4 !!SYNOPSIS
5
2 JohnMcPherson 6 __#include <stdlib.h>__
1 perry 7
2 JohnMcPherson 8 __double drand48(void);__
1 perry 9
2 JohnMcPherson 10 __double erand48(unsigned short __ ''xsubi'' __[[3]);__
1 perry 11
2 JohnMcPherson 12 __long int lrand48(void);__
1 perry 13
2 JohnMcPherson 14 __long int nrand48(unsigned short __ ''xsubi'' __[[3]);__
1 perry 15
2 JohnMcPherson 16 __long int mrand48(void);__
1 perry 17
2 JohnMcPherson 18 __long int jrand48(unsigned short __ ''xsubi'' __[[3]);__
1 perry 19
2 JohnMcPherson 20 __void srand48(long int __ ''seedval'' __);__
1 perry 21
2 JohnMcPherson 22 __unsigned short *seed48(unsigned short __ ''seed16v'' __[[3]);__
1 perry 23
2 JohnMcPherson 24 __void lcong48(unsigned short __ ''param'' __[[7]);__
1 perry 25
26
27
2 JohnMcPherson 28 !!DESCRIPTION
29 These functions generate pseudo-random numbers using the linear congruential algorithm and 48-bit integer arithmetic.
1 perry 30
2 JohnMcPherson 31 The __drand48()__ and __erand48()__ functions return non-negative double-precision floating-point values uniformly distributed between [[0.0, 1.0).
1 perry 32
2 JohnMcPherson 33 The __lrand48()__ and __nrand48()__ functions return non-negative long integers uniformly distributed between 0 and 2^31.
1 perry 34
2 JohnMcPherson 35 The __mrand48()__ and __jrand48()__ functions return signed long integers uniformly distributed between -2^31 and 2^31.
1 perry 36
2 JohnMcPherson 37 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.
1 perry 38
2 JohnMcPherson 39 All the functions work by generating a sequence of 48-bit integers, ''Xi'', according to the linear congruential formula:
1 perry 40
2 JohnMcPherson 41 __Xn+1 = (aXn + c) mod m, where n >= 0__
1 perry 42
2 JohnMcPherson 43 The parameter ''m'' = 2^48, hence 48-bit integer arithmetic is performed. Unless __lcong48()__ is called, ''a'' and ''c'' are given by:
1 perry 44
2 JohnMcPherson 45 __a = 0x5DEECE66D__
46 __c = 0xB__
1 perry 47
2 JohnMcPherson 48 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.
1 perry 49
2 JohnMcPherson 50 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.
1 perry 51
2 JohnMcPherson 52 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.
1 perry 53
2 JohnMcPherson 54 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()__.
55
56 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''.
1 perry 57
58 !!CONFORMING TO
2 JohnMcPherson 59 SVID 3
1 perry 60
61 !!NOTES
2 JohnMcPherson 62 These functions are declared obsolete by SVID 3, which states that rand(3) should be used instead.
1 perry 63
64 !!SEE ALSO
65 rand(3), random(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 8 times)