43.18 RANF and Its Supporting Routines

 Ranf is a 48 bit multiplicative congruential method RNG which produces 64 bit floating point numbers in the open interval (0,1). More precisely, it produces a sequence of  uniform variates $U_i$ based on the following formulas:

$\displaystyle U_i = \frac{S_i}{2^{48}}$     (43.1)
$\displaystyle S_{i+1} = a S_i \bmod 2^{48}$     (43.2)

where the (integer) multiplier $a$ = 0x2875a2e7b175 43.1and the (integer) default  seed $S_0$ = 0x948253fc9cd1. Note that the minimum value for $U_i$ is $1/2^{48} \cong 10^{-15}$ and the maximum value is $1 - 1/2^{48}$. 43.2

On the Cray, ranf is loaded from the Mathlib library. The workstation version is based on the  drand48 suite of library functions. Although these two libraries implement the same basic arithmetic, there is a subtle difference in that drand48 computes the next seed and returns that value divided by $2^{48}$, whereas ranf saves the old seed, computes the next, and then returns the old seed divided by $2^{48}$. The result is that the sequence from drand48 is "one ahead" of that from ranf. This problem may be solved by decrementing or incrementing the seed by one as part of setting or retrieving it, respectively, and this logic is built into the workstation versions of setranf and getranf routines below. Thus sequences generated by theBasis ranf are identical on Cray or workstation, and seed values may be carried between the two architectures without a break in the sequence.

The examples below are written as they would appear in source to be preprocessed by Mppl. In Fortran terms, ranf will return double precision on a 32 bit workstation, and real on a 64 bit architecture.


... 0x2875a2e7b17543.1
The multiplier's inverse is $ a^\prime $ = 0x5ceeb894d6dd, with $ a a^\prime \equiv 1 \bmod 2^{48} $.
.... 43.2
If stored in an IEEE 754 Standard single precision (32 bit) floating point format, the minimum is distinct from 0; however, the maximum (and many other values near it) are not distinct from 1.