Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize 64 bit random number generation #2224

Merged
merged 1 commit into from Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/util.cc
Expand Up @@ -544,8 +544,9 @@ uint64_t rand64bit()
uint64_t base = 0;
int i;

for ( i = 1; i <= 4; ++i )
base = (base << 16) | detail::random_number();
static_assert(RAND_MAX == 2147483647); // 2^32-1
for ( i = 1; i <= 2; ++i )
base = (base << 32) | detail::random_number();
return base;
}

Expand Down