Sender: nate AT cartsys DOT com Message-ID: <370A7056.1FE86F18@cartsys.com> Date: Tue, 06 Apr 1999 13:36:38 -0700 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.5 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: DJGPP's random functions. References: <3705018e AT news DOT ismi DOT net> <923349441 DOT 478285 AT eole> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Crousto wrote: > > The help file speaks about 2 functions : rand() and random(). I've noticed > that rand (or random, i don't remember ;) return always the same sequence > even with a previous srandom(biostime(0,0)), but the other one works fine. Can you show an example of this? Whichever one does this, it's a bug. > And it's a very good random generator : according to Bjarne Stroustrup > (C++'s creator), low-order bits of a random generator are often suspect, so > rand()%n is not a good way of generating a random number between 0 and n-1 > (he tips to use "(double(rand())/RAND_MAX)*n" ). BUT i've tested rand()%n, > and it gives a very good repartition... So, DJGPP is the best C > implementation!!! ;) In theory, `random' should be a better RNG, especially if you use some of its more complex modes (see the source). `rand' is just a linear congruential RNG, though a good one. However, `rand' is ANSI and `random' isn't. (The distinction between their algorithms is brought about by some obscure legal issues.) -- Nate Eldredge nate AT cartsys DOT com