geo
Posts:
38
Registered:
6/19/08
|
|
Re: Implementing the KISS4691 RNG
Posted:
Sep 7, 2010 8:54 AM
|
|
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
|
|