diff --git a/CHANGELOG.md b/CHANGELOG.md index 1988d537..103c5047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/libff/common/utils.cpp b/libff/common/utils.cpp index eb6640b0..f52a431b 100755 --- a/libff/common/utils.cpp +++ b/libff/common/utils.cpp @@ -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--; @@ -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;