Add bool conversion to fix potential bug.

Binary operations promote to int, which means that the comparisons here
are not guaranteed to do what the code is meant to do. Explicitly
converting the result of the bit-wise and means that the comparison is
guaranteed to work.