Message-ID: <368628DC.FAD5AABD@lycosmail.com> Date: Sun, 27 Dec 1998 07:32:29 -0500 From: Adam Schrotenboer X-Mailer: Mozilla 4.5 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: getting a ranged random number, how? References: <3685970D DOT 271BE4C6 AT market DOT forsale> <3685DB37 DOT 3EC8E298 AT earthlink DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com You do have a point that it can be bad, but what if when you try to use RAND_MAX, your compiler gives you a really hard time?? Don't remember exactly what happened when I tried it, it was a while back. I was trying to seed a randgen that needs 3 seeds. The easiest way was to seed the regular randgen, and then take the first 3 numbers. I eventually had to use the mod method, because nothing else could be made to work. Martin Ambuhl wrote: > DeHackEd wrote: > > > > A common practice is to do this: > > > > int num = rand() % max; > > > > Num now contains a number between 0 and (max - 1). If max is 10, it holds from 0 > > to 9. Does this help? > > It shouldn't help. If it is a common practice, then common practice is > bad. Get and read the comp.lang.c FAQ from > ftp://rtfm.mit.edu/pub/usenet/ > > -- > Martin Ambuhl (mambuhl AT earthlink DOT net) > Note: mambuhl AT tiac DOT net will soon be inactive