Versions Compared

Key

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

...

In this noncompliant code example, both bit manipulation and arithmetic manipulation are performed on the integer x. The result is a (prematurely) optimized statement that assigns 5x + 1 to x for implementations, where integers are represented as two's complement values.

Code Block
bgColor#ffcccc
int x = 50;
x += (x << 2) + 1;

...

Code Block
bgColor#ccccff
int limit = 1 << 17 - 1; // 2^17 - 1 = 131071

int03INT03-EX2: Data that is normally treated arithmetically may be treated with bitwise operations for the purpose of serialization or deserialization. This is often required for reading or writing the data from a file or network socket, It may also be used when reading or writing the data from a tightly packed data structure of bytes.

...