- #define RAND_LIMIT 32767
- /// Random number in range [-1,1]
- inline float32 RandomFloat()
- {
- float32 r = (float32)(std::rand() & (RAND_LIMIT));
- r /= RAND_LIMIT;
- r = 2.0f * r - 1.0f;
- return r;
- }
- /// Random floating point number in range [lo, hi]
- inline float32 RandomFloat(float32 lo, float32 hi)
- {
- float32 r = (float32)(std::rand() & (RAND_LIMIT));
- r /= RAND_LIMIT;
- r = (hi - lo) * r + lo;
- return r;
- }