Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!mit.eternal-september.org!.POSTED!not-for-mail From: Richard Newsgroups: comp.lang.c Subject: Re: Request for source code review of simple Ising model Date: Sat, 19 Apr 2014 14:55:27 +0100 Organization: http://www.ieee.org/ Lines: 81 Message-ID: <87r44tctkg.fsf@gmail.com> References: <87txa112hs.fsf@panda.goosenet.in> <349e1afe-6f59-4387-8eef-c29d57682750@googlegroups.com> <87wqev6631.fsf@panda.goosenet.in> <87a9bm5qhb.fsf@panda.goosenet.in> <53500B1E.5050404@verizon.net> <87bnvymmz6.fsf@panda.goosenet.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mit.eternal-september.org; posting-host="bdee7d74bb5599725cdba9fe2a37525e"; logging-data="29940"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Fku7hfPF4TbGTZN0LAFLZ+wyuKkSkGL0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:rCqlslnZ6GbIeMZntxsdr3fc+bY= sha1:j7YATpmh3ORsyi1yVI6+gZxjXP4= Xref: csiph.com comp.lang.c:43122 Udyant Wig writes: > Keith Thompson writes: > | I think I've seen PRNGs where the low-order bit actually alternates 0, > | 1, 0, 1, 0, 1, ..., but the sample implementation in the standard > | doesn't do that. > > There is a discussion of this very issue (or something extremely close > to it) in one of the assignments of Steve Summit's (fine) online C > programming classes found here: > > http://www.eskimo.com/~scs/cclass/cclass.html > > It is Exercise 8 of the third assignment: > > http://www.eskimo.com/~scs/cclass/asgn.beg/PS3.html > > The explanation is here in the answers section: > > http://www.eskimo.com/~scs/cclass/asgn.beg/PS3a.html > > | Here's a test program if anyone wants to try it. If it prints either > | "01010101..." or "10101010...", please let us know what implementation > | you're using. > | > | #include > | #include > | > | int main(void) { > | for (int i = 0; i < 64; i ++) { > | printf("%d", rand() % 2); > | } > | putchar('\n'); > | } > > I changed it thusly to calm gcc down: > > #include > #include > > int main(void) { > int i; > for (i = 0; i < 64; i ++) { > printf("%d", rand() % 2); > } > putchar('\n'); > > return 0; > } > > 1011110011010110000010110001111000111010111101001010100100011101 > > | On one of my systems, the output is >> > | 1011110011010110000010110001111000111010111101001010100100011101 > > The two outputs are equal. Independent confirmations by Emacs Lisp, > > (string-equal > "1011110011010110000010110001111000111010111101001010100100011101" > "1011110011010110000010110001111000111010111101001010100100011101") > => t > > and their MD5 sums, > > $ md5sum # Keith Thompson's output > 1011110011010110000010110001111000111010111101001010100100011101 > 89e91cff9eefca6a24afaee2809c0859 - > > $ md5sum # Udyant Wig's output > 1011110011010110000010110001111000111010111101001010100100011101 > 89e91cff9eefca6a24afaee2809c0859 - > > verify this. > Serious Q : are you taking the piss? -- "Avoid hyperbole at all costs, its the most destructive argument on the planet" - Mark McIntyre in comp.lang.c