You are generating a value between numeric_limits<T>::min()
and numeric_limits<T>::max()
. But numeric_limits<T>::min()
is probably not what you expect it to be: For floating-point types, it is the minimum positive normalized value, which is very close to zero. So your code can only get positive floating-point numbers. For float
, this would be numbers up to about 3.4e38. The vast majority of these numbers are more than 1e37, so it makes sense that those are most of the results you get.
To get possible finite values, you'd need to use the range from numeric_limits<T>::lowest()
to numeric_limits<T>::max()
. But this would lead to undefined behavior because the size of the range passed to uniform_real_distribution
must be up to numeric_limits<RealType>::max()
.
So you'd need to generate the number in a different way. For example, you can generate a non-negative number between 0 and numeric_limits<T>::max()
, and generate its sign separately.