One way to make sure that all bits are being considered is to use UCHAR_MAX from <limits.h>. Or CHAR_BIT.