pstore2
Functions
round2.hpp File Reference

Defines a function which rounds up to the next highest power of 2. More...

#include <cstdint>
Include dependency graph for round2.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::uint8_t pstore::round_to_power_of_2 (std::uint8_t v) noexcept
 
std::uint16_t pstore::round_to_power_of_2 (std::uint16_t v) noexcept
 
std::uint32_t pstore::round_to_power_of_2 (std::uint32_t v) noexcept
 
std::uint64_t pstore::round_to_power_of_2 (std::uint64_t v) noexcept
 

Detailed Description

Defines a function which rounds up to the next highest power of 2.

The implementation of these functions is based on code published in the "Bit Twiddling Hacks" web page by Sean Eron Anderson (seand.nosp@m.er@c.nosp@m.s.sta.nosp@m.nfor.nosp@m.d.edu) found at https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2. The original code is public domain.