I am surprised by C++\'s behavior when applying bit-wise not to an unsigned char.
Take the binary value 01010101b, which is 0x55, or
01010101b
0x55
The answer about integral promotion is correct.
You can get the desired results by casting and NOTting in the right order:
assert(static_cast(0xAAu) == static_cast(~0x55u));