the current rand() is only a signed short does anyone know a better randmizer that would return a UINT or float?
This is a discussion on A better random fuction within the C++ Programming forums, part of the General Programming Boards category; the current rand() is only a signed short does anyone know a better randmizer that would return a UINT or ...
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.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way