1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
// generate_canonical
#include <iostream>
#include <chrono>
#include <limits>
#include <random>
int main ()
{
// obtain a seed from the system clock:
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator (seed);
double d = std::generate_canonical<double,std::numeric_limits<double>::digits>(generator);
std::cout << "Canonical random value: " << d << std::endl;
return 0;
}
|