Mail Archives: djgpp-workers/1998/11/15/20:19:54
Subj: src/libc/ansi/stdlib/rand.c
To: dj AT delorie DOT com (DJ Delorie)
Dear DJ Delorie,
On 11-15-98 at 15:10:10 EST you wrote:
>
> * new multiplier from K.B. Williams
> * auto-initialize if the user forgets to
>
> Comments?
>
I suggest adding a comment ahead of where the multiplier is used:
/* ------------------------------------------------------------- */
/* This multiplier was obtained from Knuth, D.E., "The Art of */
/* Computer Programming," Vol 2, Seminumerical Algorithms, Third */
/* Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
/* ------------------------------------------------------------- */
The multiplier used previously originated with GNU where a modulus
of 2^48 was used. For that modulus, the original multiplier was
adequate.
My personal preference is to let an uninitialized generator produce
a deterministic result much the same that one would obtain by always
saying, srand(1). But I have no strong feeling on the matter.
I have tested the generator random() and it fails the birthday
spacings test of George Marsaglia (Knuth, op cit, page 71). A
fix is in the works.
Where should I get the latest version of random.c? I see that
there is a version in djlsr202.aip dated 10/1/95 and another
in lgpp280s.zip dated 8/20/97. Under ordinary circumstances,
I would use the one with the latest date. However, I don't
know what lgpp280s.zip is used for.
K.B. Williams
- Raw text -