Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


writing a lcrng

This topic is 5850 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

As the title implies, I'm currently trying to write a linear congruential random number generator, which looks like this: S(n+1) = ((a * S(n) + c) mod m) where m = (2^32) - 1 (as this is for 32-bit numbers) An article I've reading on the subject states that: b= a - 1 is a multiple of p, for every prime p that divides m. And the example they give uses 16 for m. That's all fine and good, but I'm really at a loss when it comes to testing this condition for all the primes up to (2^32) -1. I mean, that's a lot of primes, man! It's very likely that I'm missing something painfully obvios here, as my math skill as they say, suck. Any help would be greatly appreciated. Edit: typo. [edited by - Shi-no-Mitsukai on September 15, 2002 2:59:49 AM]

Share this post

Link to post
Share on other sites
Thank you for the reply and link.

After bit of research, I''ve decided to go with a Multiply-with-Carry generator rather than the LCG.

If anybody''s interested, you can find more information on the various types of RNGs at http://cliodhna.cop.uop.edu/~hetrick/na_faq.html


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!