Useful types, constants and utility functions.
More...
#include <array>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>
Go to the source code of this file.
|
constexpr auto | lsb (std::uint32_t x) -> std::uint8_t |
|
constexpr auto | msb (std::uint32_t x) -> std::uint8_t |
|
|
template<int begin, int end> |
constexpr auto | mask = std::uint32_t{~0u << begin & ~0u >> (32 - end)} |
| Constant value for bit masking.
|
|
template<int x> |
constexpr auto | maxdiff = std::uint32_t{mask<0, x> + 0xff} |
| Maximum difference between 32-bits integers A and B[x,32) knowing that A = B + b and b is a byte.
|
|
Useful types, constants and utility functions.
◆ lsb()
auto lsb |
( |
std::uint32_t | x | ) |
-> std::uint8_t
|
|
constexpr |
- Returns
- the least significant byte of x
◆ msb()
auto msb |
( |
std::uint32_t | x | ) |
-> std::uint8_t
|
|
constexpr |
- Returns
- the most significant byte of x
◆ maxdiff
template<int x>
auto maxdiff = std::uint32_t{mask<0, x> + 0xff} |
|
constexpr |
Maximum difference between 32-bits integers A and B[x,32) knowing that A = B + b and b is a byte.
The following equations show how the difference is bounded by the given constants:
A = B + b
A = B[0,x) + B[x,32) + b
A - B[x,32) = B[0,x) + b
A - B[x,32) <= 0xffffffff[0,x) + 0xff