Article View: comp.sources.d
Article #5179rand()
From: Andrew Klossner
Date: Tue, 09 Jan 1990 22:39
Date: Tue, 09 Jan 1990 22:39
16 lines
1192 bytes
1192 bytes
[]
"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]
Technical Details
Message-ID:
<5814@orca.wv.tek.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!zephyr.ens.tek.com!orca.wv.tek.com!frip!andrewReferences:
<815@stealth.acf.nyu.edu> <2597@cunixc.cc.columbia.edu> <2434@stealth.acf.nyu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!zephyr.ens.tek.com!orca.wv.tek.com!frip!andrew From: andrew@frip.WV.TEK.COM (Andrew Klossner) Newsgroups: comp.sources.d,comp.sources.games.bugs Subject: rand() Message-ID: <5814@orca.wv.tek.com> Date: 9 Jan 90 22:39:10 GMT References: <815@stealth.acf.nyu.edu> <2597@cunixc.cc.columbia.edu> <2434@stealth.acf.nyu.edu> Sender: andrew@orca.wv.tek.com Reply-To: andrew@frip.wv.tek.com Followup-To: comp.sources.d Distribution: usa Organization: Tektronix, Wilsonville, Oregon Lines: 16