Document next_pow2 effects and algorithm source

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
str4d 2021-06-14 17:40:43 +01:00 committed by GitHub
parent 1bbdadadc3
commit 4e56985277
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -112,6 +112,8 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
return hash; return hash;
} }
// Return 0 if x == 0, otherwise the smallest power of 2 greater than or equal to x.
// Algorithm based on <https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2>.
static uint64_t next_pow2(uint64_t x) static uint64_t next_pow2(uint64_t x)
{ {
x -= 1; x -= 1;