On Tue, Feb 04, 2003 at 16:17:48 +0300, Andrey A. Chernov wrote:
> On Tue, Feb 04, 2003 at 16:10:06 +0300, Andrey A. Chernov wrote:
> > On Tue, Feb 04, 2003 at 14:00:27 +0100, Dag-Erling Smorgrav wrote:
> > > David Schultz <[EMAIL PROTECTED]> writes:
> > > > You can do better than the present generator with 32 bits of state.
> > > > See the following page by Neal Wagner (not to be confused with David Wagner):
> > > >         http://www.cs.utsa.edu/~wagner/laws/rng.html
> > > 
> > > The attached patch, based on one of the m/k pairs suggested on that
> > > page, results in the following:
> > 
> > I just think about 62089911 and 48271 too :-)
> > 
> > There is one bug in your patch: 0 is still illegal, so my fix required.
> 
> The next bug is that there is % RAND_MAX + 1, not % RAND_MAX.
> 
> The next is not the bug but portability thing alowing different RAND_MAX:
> you need to assign *ctx first and return it % RAND_MAX + 1 next, not
> assign *ctx % RAND_MAX + 1 like you currently does.

And the next bug is 32bit overflow there:

tmp = *ctx * 62089911;

must be

tmp = (uint64_t) *ctx * 62089911;

I'll produce working variant based on your patch...

-- 
Andrey A. Chernov
http://ache.pp.ru/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to