delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/11/15/20:19:54

From: Kbwms AT aol DOT com
Message-ID: <6f7d076d.364f7d6e@aol.com>
Date: Sun, 15 Nov 1998 20:18:38 EST
To: dj AT delorie DOT com
Cc: djgpp-workers AT delorie DOT com
Mime-Version: 1.0
Subject: Re: src/libc/ansi/stdlib/rand.c
X-Mailer: AOL 3.0 16-bit for Windows sub 38
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019