I'm trying to create a random float generator. The float must be 2 decimal places and between the values 0.50 and 999.99.
I tried casting rand() to a float below, which didn't work. I'd still like to know the reason this didn't work.
saleAmount = ((float)rand() % 99950.00 + 50.00 ) / 100.00;
To make rand() a float with 2 decimal places, I did the following, which did work.
saleAmount = rand()*1.01;
I've also tried using fmod, however I can't figure out how to get the outcome between the 2 boundaries.
Any suggestions or helpful tips?