Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
sci.math.*
»
sci.math
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
RNGs: A Super KISS
Replies:
14
Last Post:
Feb 26, 2013 10:53 AM




Re: RNGs: A Super KISS
Posted:
Nov 3, 2009 7:38 PM


"Tom St Denis" <tom@iahu.ca> ha scritto nel messaggio news:4fd3c8bfe45b4359ac50f54298b14770@d21g2000yqn.googlegroups.com... On Nov 3, 10:46 am, geo <gmarsag...@gmail.com> wrote: > int refill( ) > { int i; unsigned long long t; > for(i=0;i<41790;i++) { t=7010176LL*Q[i]+carry; carry=(t>>32); Q[i]=~ > (t);} > indx=1; return (Q[0]); > }
Not to nitpick but your C code could use some work. First off, some indentation please? Second, returning a unsigned long long as "int" is not very portable.
<where is written that he return long long int like int?? <Q is "static unsigned long Q[41790]" <he return only "unsigned long" like "int" <the error could be here "Q[i]=~(t)" because in the left side is long <the other side is long long
Part of the good thing of PRNGs is that they're reproduceable. Ideally over different platforms. You should truncate the return value if you want it as "int" or change the return type. As it stands now this will produce different results on my x8632 and 64 boxes for the same seed, which is a bad thing.
Tom



