The Math Forum

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: Random numbers for C: End, at last?
Replies: 6   Last Post: Nov 29, 2004 6:54 PM

Advanced Search

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

Posts: 54
Registered: 12/13/04
Re: Random numbers for C: End, at last?
Posted: Nov 29, 2004 6:54 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I wrote:
&gt;&gt; Looking at the code in Marsaglia's post at <a href=",">,</a> I can
&gt;&gt; see a few places where a 32-bit word was implicitly required: SHR3, CONG,
&gt;&gt; FIB, LFIB4, and SWB. So yes, if you want those to behave as if they were on
&gt;&gt; a 32-bit machine, you'll need to insert appropriate AND-masking to make it
&gt;&gt; so.

and DZ replied:
&gt; I'm going with an easy but non-portable solution that works with GNU
&gt; g++/gcc. Is explicit AND-masking more efficient? Replace
&gt; typedef unsigned long UL;
&gt; in <a href=""></a> with
&gt; #include &lt;stdint.h&gt;
&gt; typedef uint32_t UL;

That looks like an excellent solution to me! I believe the compiler will do
a better job of figuring out how to accomplish the task than if you
explicitly added the masking.

Bob H

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.