diff options
Diffstat (limited to 'lib/libc/gen/rand48.3')
-rw-r--r-- | lib/libc/gen/rand48.3 | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libc/gen/rand48.3 b/lib/libc/gen/rand48.3 index 1e16cbc..0fe766a 100644 --- a/lib/libc/gen/rand48.3 +++ b/lib/libc/gen/rand48.3 @@ -65,33 +65,41 @@ r(n) is called the seed of the random number generator. For all the six generator routines described next, the first computational step is to perform a single iteration of the algorithm. .Pp +The .Fn drand48 and .Fn erand48 +functions return values of type double. The full 48 bits of r(n+1) are loaded into the mantissa of the returned value, with the exponent set such that the values produced lie in the interval [0.0, 1.0). .Pp +The .Fn lrand48 and .Fn nrand48 +functions return values of type long in the range [0, 2**31-1]. The high-order (31) bits of r(n+1) are loaded into the lower bits of the returned value, with the topmost (sign) bit set to zero. .Pp +The .Fn mrand48 and .Fn jrand48 +functions return values of type long in the range [-2**31, 2**31-1]. The high-order (32) bits of r(n+1) are loaded into the returned value. .Pp +The .Fn drand48 , .Fn lrand48 , and .Fn mrand48 +functions use an internal buffer to store r(n). For these functions the initial value of r(0) = 0x1234abcd330e = 20017429951246. .Pp @@ -106,7 +114,9 @@ holds the least significant bits. .Pp All functions share the same multiplicand and addend. .Pp +The .Fn srand48 +function is used to initialize the internal buffer r(n) of .Fn drand48 , .Fn lrand48 , @@ -117,7 +127,9 @@ of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. Additionally, the constant multiplicand and addend of the algorithm are reset to the default values given above. .Pp +The .Fn seed48 +function also initializes the internal buffer r(n) of .Fn drand48 , .Fn lrand48 , @@ -128,7 +140,9 @@ where the zeroth member specifies the lowest bits. Again, the constant multiplicand and addend of the algorithm are reset to the default values given above. +The .Fn seed48 +function returns a pointer to an array of 3 shorts which contains the old seed. This array is statically allocated, thus its contents are lost after each new call to |