I want to randomize a value between 0.03- and 0.05. I understand there is infinite values between the two numbers and that rand takes unsigned int data type. I'm wondering how to make a function to randomize double/float data type and set the limits only to two decimals
my code is the following:
double i=0.0;
double minP = 0.03;
double maxP = 0.05;
unsigned seed =time(0);
srand(seed);r
i = rand()% (maxP -minP +0.01) +minP;
Aucun commentaire:
Enregistrer un commentaire