How do i create a random number?
-
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32... THanks in advance.
-
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32... THanks in advance.
see rand() and srand(..) srand(-1); int v = (rand() % (low + high)) + low; To vote with no response is to follow the way of the coward.
-
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32... THanks in advance.
No, but you can get a pseudo-random number with srand() and rand().
-
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32... THanks in advance.
See article by: Stephen K. Park and Keith W. Miller. RANDOM NUMBER GENERATORS: GOOD ONES ARE HARD TO FIND. Communications of the ACM, New York, NY.,October 1988 p.1192 Just trying to keep the forces of entropy at bay
-
see rand() and srand(..) srand(-1); int v = (rand() % (low + high)) + low; To vote with no response is to follow the way of the coward.
Check out this page -- shows a better way to get your random numbers. When you use modular arithmetic, you focus on the low-order bits that aren't as "random" as the high-order ones. The page shows many examples of how to get a random number (int or floating point) in a given range. --Dean
-
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32... THanks in advance.
#define GetRandom(min, max) ((rand() % (int)(((max) + 1) - (min))) + (min)) //get a random number between min and max
Remember something likesrand(GetTickCount());
first... - Anders Money talks, but all mine ever says is "Goodbye!"