lundi 27 août 2018

Uniform_real does not accept numeric_limits::lowest()

I've got a line:

std::uniform_real_distribution<T> distribution(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max()); It compiles but crashes on Debug(VS 2017CE). My guess is that, according to documentation of uniform_real:

Requires that a ≤ b and b-a ≤ std::numeric_limits::max()

when my b is ::max() and a is ::lowest(), condition :

b-a ≤ std::numeric_limits::max()

is not fulfilled as b-a it basically doubles value of max. Is there any work around for this so that I will keep such a wide numbers range? ::min() works perfectly but omits negative values.

Aucun commentaire:

Enregistrer un commentaire