Random Number Generator Question

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Random Number Generator Question

      Hi Everyone,

      I am somewhat new to C++ programming and I have a question about the following code:

      Source Code

      1. class GCCRandom
      2. {
      3. private:
      4. // DATA
      5. unsigned int rseed;
      6. unsigned int rseed_sp;
      7. unsigned long mt[CMATH_N]; /* the array for the state vector */
      8. int mti; /* mti==N+1 means mt[N] is not initialized */
      9. ...
      10. }


      I'm curious to what value CMATH_N holds because I am trying to take some of the ideas from the book and make a java implementation of it for an engine I am currently making. I was wondering if this is something worth doing/can be done, and if it is, how do I find that value of CMATH_N so that I can use that in java to create the array mt.
    • RE: Random Number Generator Question

      The value of CMATH_N is 624. You can find all of those definitions in Math.h in the #define's.

      The GCCRandom class is an implementation of the Mersenne Twister algorithm, which is described here:
      en.wikipedia.org/wiki/Mersenne_twister

      At the bottom of the page, you'll see links to implementations in various languages. The one for Java can be found here:
      cs.gmu.edu/~sean/research/

      -Rez