Expressions and statements
ES.101
Use unsigned types for bit manipulation
Reason
Unsigned types support bit manipulation without surprises from sign bits.
Example
unsigned char x = 0b1010'1010;
unsigned char y = ~x; // y == 0b0101'0101;
Note
Unsigned types can also be useful for modular arithmetic. However, if you want modular arithmetic add comments as necessary noting the reliance on wraparound behavior, as such code can be surprising for many programmers.
Enforcement
- Just about impossible in general because of the use of unsigned subscripts in the standard library
- ???