Bitwise NOT in C

Level 119 keystrokes

Performs bitwise NOT operation on 0, resulting in -1.

C code

// ~ is the bitwise NOT operator (inverts all bits)
// ~0 inverts all bits to 1, which is -1 in two's complement
1printf("%d\n", ~0);

Output

-1
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • "× 2
  • ,× 1
  • ;× 1
  • (× 1
  • )× 1
  • \× 1
  • %× 1
  • ~× 1

More C examples at level 1

← C typing practice