Skip to content

Instantly share code, notes, and snippets.

@chessai
Created February 5, 2019 18:42
Show Gist options
  • Save chessai/371956da017999d2716b0e8af266d3c8 to your computer and use it in GitHub Desktop.
Save chessai/371956da017999d2716b0e8af266d3c8 to your computer and use it in GitHub Desktop.
reverseBits :: Word8 -> Word8
reverseBits b' =
let b = fromIntegral b' :: Word32
!x = ((((b * 0x0802 .&. 0x22110) .|. ((b * 0x8020) .&. 0x88440)) * 0x10101) `unsafeShiftR` 16
in fromIntegral x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment