Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!dkuug!freja.diku.dk!njk From: njk@diku.dk (Niels J|rgen Kruse) Newsgroups: comp.lang.c Subject: Re: random() error in Turbo C++ Message-ID: <1990Sep9.163304.14605@diku.dk> Date: 9 Sep 90 16:33:04 GMT References: <118662@linus.mitre.org> <17607@haddock.ima.isc.com> Organization: Department Of Computer Science, University Of Copenhagen Lines: 20 daveg@near.cs.caltech.edu (Dave Gillespie) writes: >>>>>> On 8 Sep 90 20:15:20 GMT, njk@diku.dk (Niels J|rgen Kruse) said: >> This require 2 divisions however. Here is an algorithm, that >> only require one division: I used rand() because Karl Heuer did and because it is the ANSI standard interface for getting random numbers. Nothing other than inertia prevents rand() from being good. Good random number generators don't have to be slower than bad ones. Just plug a good random number generator into the code i gave instead of rand(), if the one you are using is bad. >Most rand() implementations use linear congruential random number >generators, which are notorious for having unpleasant properties >in their low bits. Experts recommend always dividing instead of >mod'ing, so that you are using the high bits of the result of >rand(). Oh. So experts use rand()? ;-) -- Niels J|rgen Kruse DIKU Graduate njk@diku.dk