Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: changed the type of the left operand of left shift from int to unsigned long to avoid undefined behaviour and implicit type cast

...

Code Block
bgColor#CCCCFF
langc
const unsigned long mask = (11UL << ((sizeof(unsigned long) * CHAR_BIT) - 1))
unsigned long x;

/* Initialize x */

x = (x ^ mask) + 1;

...