Porytiles
Loading...
Searching...
No Matches
reverse_bits.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace porytiles {
6
15constexpr uint8_t reverse_bits(uint8_t b)
16{
17 b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
18 b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
19 b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
20 return b;
21}
22
23} // namespace porytiles
constexpr uint8_t reverse_bits(uint8_t b)
Reverses the bits in a byte.