jeudi 17 décembre 2020

Random number generator only adds numbers c++ [closed]

I'm reading numbers from an interval in my .txt file. Let's just say it looks something like this:

parameter[100, 10000]

My program reads the parameterMIN and parameterMAX (100 and 10000) And than I try to random generate numbers in that interval but it only generates the 1st number then it just keep adding +2. I'm using object oriented programming. . It's weird because for other interval that I have in file it adds +3 and for one interval it works just fine. Any ideas?

interval_osvetljenost = inter_osvetMIN + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (inter_osvetMAX - inter_osvetMIN)));
        interval_temperatura = inter_tempMIN + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (inter_tempMAX - inter_tempMIN)));
        interval_vlaznost = inter_vlazMIN + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (inter_vlazMAX - inter_vlazMIN)));



Aucun commentaire:

Enregistrer un commentaire