rand48.3 (7f3dea244c40159a41ab22da77a434d7c5b5e85a) | rand48.3 (c6ff3a1bf74d96278726113478b2c66884aab584) |
---|---|
1\" Copyright (c) 1993 Martin Birgmeier 2.\" All rights reserved. 3.\" 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. 7.\" 8.\" This software is provided ``as is'', and comes with no warranties --- 36 unchanged lines hidden (view full) --- 45.Ft "unsigned short *" 46.Fn seed48 "unsigned short xseed[3]" 47.Ft void 48.Fn lcong48 "unsigned short p[7]" 49.Sh DESCRIPTION 50The 51.Fn rand48 52family of functions generates pseudo-random numbers using a linear | 1\" Copyright (c) 1993 Martin Birgmeier 2.\" All rights reserved. 3.\" 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. 7.\" 8.\" This software is provided ``as is'', and comes with no warranties --- 36 unchanged lines hidden (view full) --- 45.Ft "unsigned short *" 46.Fn seed48 "unsigned short xseed[3]" 47.Ft void 48.Fn lcong48 "unsigned short p[7]" 49.Sh DESCRIPTION 50The 51.Fn rand48 52family of functions generates pseudo-random numbers using a linear |
53congruential algorithm working on integers 48 bits in size. The | 53congruential algorithm working on integers 48 bits in size. 54The |
54particular formula employed is 55r(n+1) = (a * r(n) + c) mod m 56where the default values are 57for the multiplicand a = 0xfdeece66d = 25214903917 and 58the addend c = 0xb = 11. The modulo is always fixed at m = 2 ** 48. 59r(n) is called the seed of the random number generator. 60.Pp 61For all the six generator routines described next, the first 62computational step is to perform a single iteration of the algorithm. 63.Pp 64.Fn drand48 65and 66.Fn erand48 | 55particular formula employed is 56r(n+1) = (a * r(n) + c) mod m 57where the default values are 58for the multiplicand a = 0xfdeece66d = 25214903917 and 59the addend c = 0xb = 11. The modulo is always fixed at m = 2 ** 48. 60r(n) is called the seed of the random number generator. 61.Pp 62For all the six generator routines described next, the first 63computational step is to perform a single iteration of the algorithm. 64.Pp 65.Fn drand48 66and 67.Fn erand48 |
67return values of type double. The full 48 bits of r(n+1) are | 68return values of type double. 69The full 48 bits of r(n+1) are |
68loaded into the mantissa of the returned value, with the exponent set 69such that the values produced lie in the interval [0.0, 1.0). 70.Pp 71.Fn lrand48 72and 73.Fn nrand48 74return values of type long in the range 75[0, 2**31-1]. The high-order (31) bits of --- 38 unchanged lines hidden (view full) --- 114.Pp 115.Fn seed48 116also initializes the internal buffer r(n) of 117.Fn drand48 , 118.Fn lrand48 , 119and 120.Fn mrand48 , 121but here all 48 bits of the seed can be specified in an array of 3 shorts, | 70loaded into the mantissa of the returned value, with the exponent set 71such that the values produced lie in the interval [0.0, 1.0). 72.Pp 73.Fn lrand48 74and 75.Fn nrand48 76return values of type long in the range 77[0, 2**31-1]. The high-order (31) bits of --- 38 unchanged lines hidden (view full) --- 116.Pp 117.Fn seed48 118also initializes the internal buffer r(n) of 119.Fn drand48 , 120.Fn lrand48 , 121and 122.Fn mrand48 , 123but here all 48 bits of the seed can be specified in an array of 3 shorts, |
122where the zeroth member specifies the lowest bits. Again, | 124where the zeroth member specifies the lowest bits. 125Again, |
123the constant multiplicand and addend of the algorithm are 124reset to the default values given above. 125.Fn seed48 126returns a pointer to an array of 3 shorts which contains the old seed. 127This array is statically allocated, thus its contents are lost after 128each new call to 129.Fn seed48 . 130.Pp --- 31 unchanged lines hidden --- | 126the constant multiplicand and addend of the algorithm are 127reset to the default values given above. 128.Fn seed48 129returns a pointer to an array of 3 shorts which contains the old seed. 130This array is statically allocated, thus its contents are lost after 131each new call to 132.Fn seed48 . 133.Pp --- 31 unchanged lines hidden --- |