Fix off-by-one error in PRNG. BUG= Review URL: https://codereview.webrtc.org/1412183002 Cr-Commit-Position: refs/heads/master@{#10328}
diff --git a/webrtc/test/random.cc b/webrtc/test/random.cc index 8877ed4..c4c405f 100644 --- a/webrtc/test/random.cc +++ b/webrtc/test/random.cc
@@ -22,11 +22,11 @@ } float Random::Rand() { - const float kScale = 1.0f / 0xffffffff; - float result = kScale * b_; + const double kScale = 1.0f / (static_cast<uint64_t>(1) << 32); + double result = kScale * b_; a_ ^= b_; b_ += a_; - return result; + return static_cast<float>(result); } int Random::Rand(int low, int high) {
diff --git a/webrtc/test/random.h b/webrtc/test/random.h index 9a0bc9e..5cc54f2 100644 --- a/webrtc/test/random.h +++ b/webrtc/test/random.h
@@ -22,10 +22,10 @@ public: explicit Random(uint32_t seed); - // Return pseudo-random number in the interval [0.0, 1.0]. + // Return pseudo-random number in the interval [0.0, 1.0). float Rand(); - // Return pseudo rounded random number in interval [low, high]. + // Return pseudo-random number mapped to the interval [low, high]. int Rand(int low, int high); // Normal Distribution.