SOLVED: More randomness
General and Desktop
4
Posts
2
Posters
2.6k
Views
1
Watching
-
wrote on 28 Jul 2011, 19:17 last edited by
I've set up a simple condition to generate a random number based on a seed value. The code is below. The problem is that no matter what I assign as the seed value, I keep getting the same sequence again and again.
What am I doing wrong?
@
qsrand(QTime::currentTime().msec());
returnValue = ((rand() % (m_iUpperBound - m_iLowerBound + 1)) + m_iLowerBound);
@ -
wrote on 28 Jul 2011, 19:20 last edited by
Never mind. I figured it out. Stupid error.
-
wrote on 29 Jul 2011, 08:34 last edited by
Let me guess, you were setting the seed every time you wanted a random number? Typically you would seed the generator once, in the constructor say.
-
wrote on 29 Jul 2011, 12:29 last edited by
Yep! That's what I did.
2/4