Click to See Complete Forum and Search --> : srand() and rand() functions


Gladywin Yap
October 12th, 1999, 02:03 AM
Hi all,

Is the srand() and rand() functions in VC++ an ANSI standard? Can I assume that if I were to use any other C compiler, the generated sequence of random number will be the same?

Does anyone know or has the source code of any random number generator that allows seeding?

Thanks in advance for any help.


Gladywin

Jack Shainsky
October 12th, 1999, 03:44 AM
The rand and srand are ANSI standard functions for random number generator, but I don't think that ANSI tells to compiler developers, which algorithm to implement in this generator. So, it guarantees to you than rand or srand call will give you random number, but it doesn't guarantees to you that these numbers will be same on all compiler.
And if you search for random number generator algorythm, there are a lot of them. For example, look at Random number page in Yahoo : http://dir.yahoo.com/Science/Mathematics/Numerical_Analysis/Numbers/Random_Numbers/.


Jack.