With C ++ 11, you can do the following:
Include random header:
#include<random>
Define PRNG and distribution:
std::default_random_engine generator;
std::uniform_real_distribution<double> distribution(0.0,1.0);
Get a random number
double number = distribution(generator);
In on this page and in on this page you can find links to uniform_real_distribution.
source
share