jeudi 26 mai 2022

How do I generate random numbers between -1 and +1 in c++? [closed]

How do I use srand and rand to generate random number between -0.5 and +0.5?

srand( (signed)time( NULL ) );
double z =  (float) rand()/RAND_MAX;

What changes should I make in the above code?

Aucun commentaire:

Enregistrer un commentaire