delorie.com/archives/browse.cgi | search |
From: | "Crousto" <crousto AT infonie DOT be> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: DJGPP's random functions. |
Date: | Mon, 5 Apr 1999 23:56:42 +0200 |
Organization: | Ye 'Ol Disorganized NNTPCache groupie |
Lines: | 17 |
Message-ID: | <923349441.478285@eole> |
References: | <3705018e AT news DOT ismi DOT net> |
NNTP-Posting-Host: | eole.infonie.be |
X-Newsreader: | Microsoft Outlook Express 4.72.3110.5 |
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3110.3 |
Cache-Post-Path: | eole!unknown AT ppp-bruxelles-2-185 DOT infonie DOT be |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
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. 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!!! ;) Crousto crousto AT infonie DOT be
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |