Answers for "c++ random float"

C++
-1

c++ random float

float get_random()
{
    static std::default_random_engine e;
    static std::uniform_real_distribution<> dis(0, 1); // rage 0 - 1
    return dis(e);
}
Posted by: Guest on April-20-2021
-1

random number generator for floats

float r3 = LO + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(HI-LO)));
Posted by: Guest on December-06-2020

Browse Popular Code Answers by Language