random float c++ code example
Example 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);
}
Example 2: random number generator for floats
float r3 = LO + static_cast (rand()) /( static_cast (RAND_MAX/(HI-LO)));