I'm trying to make a model of a zombie apocalipse in c++ using simple structs and a when I'm randomizing the population, I need some fields of the struct to have a value in the interval [0..1[. As I'm interested in a more statistically correct analysis, I choose to use the mt19937 engine to generate my "data". When playing around with this PRNG I couldn't find a way to generate a number in said range. Here's the code that I came up with:
int
main ( int argc, char** argv )
{
mt19937_64 newr ( time ( NULL ) );
std::cout << newr.max ( ) << endl;
std::cout << newr.min ( );
double rn;
for(;;){
rn = newr()/newr.max ();
std::cout << rn << std::endl;
}
}
But the only outputs that I get for the loop are zeros (0). A small print of the output is down:
18446744073709551615
0
0
0
0
0
0
0
0
0
0
0
Any ideas?
Aucun commentaire:
Enregistrer un commentaire