7
tbodt
7y

double RandDouble(double min, double max) {
double rand = (double) RandomGen::GetRand32() / UINT32_MAX;
return (rand * (max - min)) + min;
}

I wrote this function 2 months ago and until now assumed it was working.

Turns out GetRand32 has a range up to INT32_MAX, not UINT32_MAX. So this function would only ever select the first half of the range.

You gotta be fucking kidding me...

Comments
Add Comment