Boost logo

Boost Users :

From: John W (jwdevel_at_[hidden])
Date: 2020-10-01 21:45:45


I have a fixed-point number class (based on libfixmath) which in code
largely behaves like a float due to various operator overloading.

Now, I am trying to generate random numbers with them.
Uniform random is easy enough — just reinterpret some random bits as
my fixedpoint type.

However, I'd like to have other distributions, like
boost::random::normal_distribution.

But from what I can tell, Boost.Random might have some baked-in
assumptions about only working on float/double/long double.

Is that correct?

Or are there ways I can more-or-less transparently use
boost::random::xxx distributions with my custom type?

Basically, I want to know how much the <RealType> template argument
can be abused.

In std::random, there is some clear language[1], saying:
"The result type generated by the generator. The effect is undefined
if this is not one of float, double, or long double."

and I believe boost::random aims to be in agreement with std::random,
generally. But I could not find such clear language in the
Boost.Random docs.

Thanks
-John

[1] https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net