Random doubles are always endless

I have the following:

    std::random_device rd;
    std::mt19937_64 randEng(rd());
    std::uniform_real_distribution<double> rg(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());

    for(size_t i = 0; i < numToGenerate; i++){
        nums[i] = rg(randEng);
        std::cout << nums[i] << std::endl;
    }   

Where numsis the vector given fornumToGenerate

Every number that is printed says inf, I realized that I set this to get random numbers between them in this case -1.79769e+308and 1.79769e+308, as it happens on my machine. What am I doing wrong here in setting up this random number generator

+4
source share
1 answer

Probably the calculation of the pseudo-random number includes the difference (max-min). For example, to calculate a random number between Aand B, a simple approach:

x = A + rnd*(B - A)

rnd - 0 1. , , , , "".

A + rnd*infinite , rnd , NaN, .

+7

All Articles