Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math

Topic: Implementing the KISS4691 RNG
Replies: 16   Last Post: Sep 8, 2010 3:12 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
geo

Posts: 38
Registered: 6/19/08
Re: Implementing the KISS4691 RNG
Posted: Sep 7, 2010 8:54 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Sep 5, 5:19 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> On 09/ 6/10 09:04 AM, geo wrote:
>
> <snip>
>
>
>

> > Thus I suggest using this listing for the MWC function
> > in KISS4691:
> > ------------------------------------------------

>
> >   unsigned long MWC(void)
> >   {unsigned long t,x; static c=0,j=4691;

>
> static what?
>

> >     j=(j<4690)? j+1:0;
> >     x=Q[j]; t=(x<<13)+c;
> >       if(t<c) {c=(x>>19)+1; t=t+x;}
> >       else {t=t+x; c=(x>>19)+(t<x);}
> >     return (Q[j]=t);
> >   }

>
> This code must be making assumptions about sizes, it gives different
> results in 32 and 64 bit mode.
>
>
>
>
> Try compiling with warnings enabled!
>
> --
> Ian Collins


Evidently I had in mind: here is a list of unsigned longs,

unsigned long t,x; static c=0,j=4691;

among which I want c and j to be saved after each call.

Wrong thinking, but why did the compiler let me get away with it?

Sorry for that; I'll first try full warnings from now on.

George Marsaglia




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.