random numbers - long double

Greetings,

another question:

I would like to sample random numbers of type long double.
Right now, I am drawing double numbers within the interval (a,b) via:

1
2
3
4
double var;
std::mt19937 gen(seed);
std::uniform_real_distribution<> dist(a,b);
var = dist(gen);


If I want to take long double values, is it enough to simply define "var" as a long double?


Best,

PiF
I'm guessing you want the generated numbers to be long doubles, instead of generating doubles and then casting to long doubles. If so, the answer's no, but you can give the uniform_real_distribution a template argument to change the types of numbers that it generates:
std::uniform_real_distribution<long double> dist(a,b);

-Albatross
Topic archived. No new replies allowed.