Consider what std::uniform_real_distribution .
Produces random floating-point values i uniformly distributed on the segment [a, b)
So, this is between std::numeric_limits<foat>::min() and std::numeric_limits<float>::max() , including the former, but excluding the latter. What values return these limits? They return FLT_MIN and FLT_MAX respectively. Well what is it?
minimum normalized positive floating point number
The most representable finite floating point number
Since neither {positive, negative} infinity nor NaN are in the range of finite numbers, they are not generated.
As Christopher Oil noted, note that FLT_MIN and finally std::numeric_limits<foat>::min() is the smallest positive representable value.
As Chris Dodd noted, if the range [min, max) exceeds std::numeric_limits<float>::max() , then you will get undefined behavior, in which case any output is possible, including creating infinity.
source share