Skip to content

Fix is_power_of_two for n > 2^32 #54

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

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _Special thanks to all downstream projects upstreaming their patches!_
- #52 Change default build flags to work with Mac OS, and add instructions for finding macOS openSSL installation

### Bug fixes
- #54 Fix is_power_of_two for n > 2^32
- #19 Fix is_little_endian always returning true
- #20 Fix operator+ not contributing to alt_bn_128 profiling opcount
- #26 Remove unused warnings in release build
Expand Down
3 changes: 3 additions & 0 deletions libff/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace libff {

/** Round n to the next power of two.
* If n is a power of two, return n */
size_t get_power_of_two(size_t n)
{
n--;
Expand All @@ -24,6 +26,7 @@ size_t get_power_of_two(size_t n)
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n |= n >> 32;
n++;

return n;
Expand Down