1 .\" Copyright (c) 1993 Martin Birgmeier
2 .\" All rights reserved.
4 .\" You may redistribute unmodified or modified versions of this source
5 .\" code provided that the above copyright notice and this and the
6 .\" following conditions are retained.
8 .\" This software is provided ``as is'', and comes with no warranties
9 .\" of any kind. I shall in no event be liable for anything that happens
10 .\" to anyone/anything when using this software.
12 .\" @(#)rand48.3 V1.0 MB 8 Oct 1993
28 .Nd pseudo random number generators and initialization routines
36 .Fn erand48 "unsigned short xseed[3]"
40 .Fn nrand48 "unsigned short xseed[3]"
44 .Fn jrand48 "unsigned short xseed[3]"
46 .Fn srand48 "long seed"
47 .Ft "unsigned short *"
48 .Fn seed48 "unsigned short xseed[3]"
50 .Fn lcong48 "unsigned short p[7]"
53 The functions described in this manual page are not cryptographically
55 Cryptographic applications should use
62 family of functions generates pseudo-random numbers using a linear
63 congruential algorithm working on integers 48 bits in size.
65 particular formula employed is
66 r(n+1) = (a * r(n) + c) mod m
67 where the default values are
68 for the multiplicand a = 0x5deece66d = 25214903917 and
69 the addend c = 0xb = 11.
70 The modulo is always fixed at m = 2 ** 48.
71 r(n) is called the seed of the random number generator.
73 For all the six generator routines described next, the first
74 computational step is to perform a single iteration of the algorithm.
81 return values of type double.
82 The full 48 bits of r(n+1) are
83 loaded into the mantissa of the returned value, with the exponent set
84 such that the values produced lie in the interval [0.0, 1.0).
91 return values of type long in the range
93 The high-order (31) bits of
94 r(n+1) are loaded into the lower bits of the returned value, with
95 the topmost (sign) bit set to zero.
102 return values of type long in the range
104 The high-order (32) bits of
105 r(n+1) are loaded into the returned value.
113 use an internal buffer to store r(n).
115 the initial value of r(0) = 0x1234abcd330e = 20017429951246.
122 use a user-supplied buffer to store the seed r(n),
123 which consists of an array of 3 shorts, where the zeroth member
124 holds the least significant bits.
126 All functions share the same multiplicand and addend.
131 is used to initialize the internal buffer r(n) of
136 such that the 32 bits of the seed value are copied into the upper 32 bits
137 of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e.
138 Additionally, the constant multiplicand and addend of the algorithm are
139 reset to the default values given above.
144 also initializes the internal buffer r(n) of
149 but here all 48 bits of the seed can be specified in an array of 3 shorts,
150 where the zeroth member specifies the lowest bits.
152 the constant multiplicand and addend of the algorithm are
153 reset to the default values given above.
157 returns a pointer to an array of 3 shorts which contains the old seed.
158 This array is statically allocated, thus its contents are lost after
164 allows full control over the multiplicand and addend used in
177 An array of 7 shorts is passed as argument; the first three shorts are
178 used to initialize the seed; the second three are used to initialize the
179 multiplicand; and the last short is used to initialize the addend.
180 It is thus not possible to use values greater than 0xffff as the addend.
182 Note that all three methods of seeding the random number generator
183 always also set the multiplicand and addend for any of the six