I want to generate random numbers in the whole double range. Doing it like
std::uniform_real_distribution<double> doubleDist(std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::max());
produces IND / NaN, though. It took me a while to understand that this is according to documentation:
Requires that
a ≤ b
andb-a ≤ std::numeric_limits<RealType>::max()
Clearly std::numeric_limits<double>::max() - std::numeric_limits<double>::lowest()
is larger than ::max
, since :lowest
is negative (unlike ::min
).
Why can't I generate numbers between lowest and max this way and what is the rationale behind?
Aucun commentaire:
Enregistrer un commentaire