Hi,
could you please give me a hint about the algorithm that c++ uses when we use rand () command.
there are many algorithm. but most simple one is:Linear Congruential Generator(LCG)
does c++ use (LCG) when we use rand () ??
thanks for your help
Hi,
could you please give me a hint about the algorithm that c++ uses when we use rand () command.
there are many algorithm. but most simple one is:Linear Congruential Generator(LCG)
does c++ use (LCG) when we use rand () ??
thanks for your help
I don't think the standard defines rand()'s algorithm.
But have a look here(C++11):
Pseudo-random number generation - Cppreference
Why not find it out yourself?
Write a program that uses rand() and step into it with a debugger.
My compiler uses:
Yours might differ.Code:return( ((ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L) >> 16) & 0x7fff );
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
thanks for your help
I think srand is what you looking for... check cplusplus reference