If you use values as bit fields, then what's the point of comparing bit fields of different sizes? Will it bring you meaningful results?
Nevertheless, both operands will be increased to a minimum size of int / unsigned with signature depending on the signature of the source operands. Then these advanced values will be compared with the bitwise operator.
This behaves like your second example: the smaller one is padded with zeros on the MSB side (if you prefer it on the LSB side).
If one operand is signed and negative and the other unsigned, the negative will be converted to a congruent unsigned number before the bit occurs.
If instead of integers you mean std::bitset , you cannot perform bitwise operations on bits of different sizes.
source share