Bit tricks

Some bit-twiddling tricks, I might add some more in the future