prime and bit manipulation