> 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
> 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.
Boost.Random works with custom floating point types, but I
don't recommend using it with fixed point. The algorithms
will likely compile as long as you provide conversions
from built in numeric types and overloads of cmath functions,
but they are written with floating point in mind and may
lose precision when applied to fixed point.
> In std::random, there is some clear language, 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.
Boost.Random is generally more permissive than the standard.