>>>>> thus on Fri, 10 Jul 1998 12:20:13 -0400, George wrote: > On Fri, 10 Jul 1998, George wrote: >> return ( (double)y / (unsigned long)0xffffffff ); /* reals */ >> /* return y; */ /* for integer generation */ >> 1) No floating point math. >> i.e.; "return ( (double)y / (unsigned long)0xffffffff ); /* reals */" > Oops, ne'ermind on that point. :) > The simplicity still applies though. The floating point is intended for a real number range of 0 .. 1. Getting a truly random distributed range from 1 to N where N > 1, you have to start with a pseudo random number from 0 .. 1, and multiply by N - 1 and add 1 to the final product. Using a modulus (especially on older BSD's) you might as well use the compiler's builtin random(), and scrap the random that comes in circle, since it's original intent is now useless. Modulus as a rule can be just as disruptive as a random that fails to use all bits of a number. d. +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST