SOLVED: More randomness

  • 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?

    returnValue = ((rand() % (m_iUpperBound - m_iLowerBound + 1)) + m_iLowerBound);

  • Never mind. I figured it out. Stupid error.

  • 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.

  • Yep! That's what I did.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.