I have the following lines:
float t = 120 * (rand() / float(RAND_MAX));
cout << t << "\n";
This should be giving me values between 0 and 120, and many are. However, lots of values I get are far outside the range, and have varying amounts of numbers in the result (aa.aaa vs aa.a or aaa.aaaa). I know that this should not be having any issues. Am I missing something? Or could this be indicative of another problem elsewhere in my code?
Some sample output:
53.2672 65.7823 74.5688 54.906 107.654 112.27 80.8935 55.3187 24.7066 7.42941 63.4948 40.0222 29.8148 26.2249 69.5444 37.5757 239.7498 24.55429 226.9441 274.1837 51.3808 271.7253 2106.269 76.8192 298.4517
Aucun commentaire:
Enregistrer un commentaire