X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Wed, 5 Sep 2007 11:11:13 -0400 Message-Id: <200709051511.l85FBDts032068@envy.delorie.com> From: DJ Delorie To: Gordon DOT Schumacher AT seagate DOT com CC: djgpp AT delorie DOT com In-reply-to: (Gordon DOT Schumacher AT seagate DOT com) Subject: Re: random() : What am I doing wrong? References: Errors-To: nobody AT delorie DOT com > That depends if you care about equidistribution; if you do, you'd be > better off ... not using random() in the first place. > If you do a modulo, you effectively "fold" the original random number > space back on itself - and the numbers will be weighted towards the > first "n" (where n is the remainder of the division). The code above > actually scales the number so you don't have that problem. This has *exactly* the same problem, it just involves different numbers being weighted heavier. If you really want equidistribution, you have to check for the last couple of numbers, and call random() again if you get them.