Advertisement

Trying to get a Pseudo random floating point number

Started by June 08, 2002 01:12 PM
1 comment, last by shaddowofadream 22 years, 6 months ago
Ive done a quick search on the MSDN libaries and havent come up with anything useful my first impression leads me to think... eg a random number between 0..1 with 2 units of precission.... you could randomly generate a value for 0..1000 then divide it by a 1000 ? would this work ? or is their any easier way ?
"... We live on a placid island of ignorance in the midst of black seas of infinity, and it was not meant that we should voyage far." - H.P. Lovecraft The Call to Cthulu
Try

float frand() { return float(rand())/RAND_MAX; }
---visit #directxdev on afternet <- not just for directx, despite the name
Advertisement
between 0 and 1 with 2 digits after the decimal would be divide by 100, or mulitply by 0.01

float inline frand (){	return (std::rand () % 100)*.01; } 

This topic is closed to new replies.

Advertisement