Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Avoid performing bitwise and arithmetic operations on the same data. In particular, it is frequently the case that bitwise operations are performed on arithmetic values as a form of premature optimization. Bitwise operators include the unary operator { ~}, and the binary operators <<, >>, &, { ^}, and |. Although such operations are valid and will compile, they can reduce code readability. Declaring a variable as containing a numeric value or a bitmap makes the programmer's intentions clearer and the code more maintainable.

...

Although this is a legal manipulation, the result of the shift depends on the underlying representation of the integer type and is consequently implementation-defined. Additionally, the readability of the code is reduced.

...