I tried to generate random numbers between 0-1 in C++ with the following:
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(0)) ;
cout << ((double) rand() / (RAND_MAX));
}
However, the output is a number that always starts with 0.26XXXX. Only the last four digits are changing. I couldn't see what I missed. All google result uses similar techniques as well. I will appreciate any input.
Aucun commentaire:
Enregistrer un commentaire