int RandomNumberGenerator::NextInt(int max) {
- DCHECK_LE(0, max);
+ DCHECK_LT(0, max);
// Fast path if max is a power of 2.
if (IS_POWER_OF_TWO(max)) {
}
+int64_t RandomNumberGenerator::NextInt64() {
+ uint64_t lo = bit_cast<unsigned>(Next(32));
+ uint64_t hi = bit_cast<unsigned>(Next(32));
+ return lo | (hi << 32);
+}
+
+
void RandomNumberGenerator::NextBytes(void* buffer, size_t buflen) {
for (size_t n = 0; n < buflen; ++n) {
static_cast<uint8_t*>(buffer)[n] = static_cast<uint8_t>(Next(8));