• Advertisement
Sign in to follow this  

random number generators and different CPU's

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im using the rand48 family of functions (srand48,drand48...) for generating random number sequences. My question is whether I will be getting the same sequence of random numbers, given the same seed, but on another CPU type? Will I get the same sequence on a SUN server as on a HP?

Share this post


Link to post
Share on other sites
Advertisement
You *should*. If the generators use Integers internally, then yes. However, if they use floating point variables, then its really up to the way the processor deals with precision and rounding off.

Share this post


Link to post
Share on other sites
rand48 always uses integers internally. So as long as you're generating integers rather than floating point numbers, yes, it should be the same sequence.

Share this post


Link to post
Share on other sites
So long as you're using the same library and thus the same PRNG algorithm, the results should stay the same regardless of what ISA they compile to. (See above posts for floating-point issues).

Share this post


Link to post
Share on other sites
Personally I'd be tempted to use a portable random number generator that you know will always generate the same sequence regardless of architecture, rather than a C library function which could be implemented differently on different platforms.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement