uint32_t reverseBits(uint32_t n) { auto strBits = bitset<32>(n).to_string(); return static_cast<uint32_t>(bitset<32>(string(strBits.crbegin(), strBits.crend())).to_ulong()); }