Bit manipulation and testing functions