the current rand() is only a signed short does anyone know a better randmizer that would return a UINT or float?
the current rand() is only a signed short does anyone know a better randmizer that would return a UINT or float?
int a; don't make a program without it.
First RAND_MAX isn't guaranteed to be a short
If you want a larger rand, then simply do something like rand() * rand()
If you want a float in the range 0..1, then do (float)rand() / RAND_MAX, and scale accordingly
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks for the info
int a; don't make a program without it.
You can try the Mersenne Twister algorithm.
Someone has implemented it in C++ here:
http://www-personal.engin.umich.edu/...neTwister.html
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)