[comp.sources.d] rand

andrew@frip.WV.TEK.COM (Andrew Klossner) (01/10/90)

[]

	"It's generally safe to use rand() modulo various small
	numbers, even for linear congruential sequences; unless those
	small numbers are all powers of two and you're very unlucky,
	the small period of rand()'s low-order bits won't affect
	anything."

I vehemently disagree.  It's generally unsafe to generate a linear
congruential sequence, then take the elements modulo various small
numbers.

This is discussed in the standard reference:  Knuth volume II.

  -=- Andrew Klossner   (uunet!tektronix!frip.WV.TEK!andrew)    [UUCP]
                        (andrew%frip.wv.tek.com@relay.cs.net)   [ARPA]

brnstnd@stealth.acf.nyu.edu (01/11/90)

In article <5814@orca.wv.tek.com> andrew@frip.wv.tek.com writes:
> It's generally unsafe to generate a linear
> congruential sequence, then take the elements modulo various small
> numbers.
>
> This is discussed in the standard reference:  Knuth volume II.

Knuth does not make that statement, and it simply isn't true for the
application in question.

---Dan