Bitwise NOT in C++

Level 121 keystrokes

Applies bitwise NOT to 0 and prints the result, -1.

C++ code

// ~ flips every bit, so all the 0 bits of the int 0 become 1
// In two's complement, an int with all bits set to 1 is -1
1cout << (~0) << endl;

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.

  • <× 4
  • ;× 1
  • (× 1
  • )× 1
  • ~× 1

More C++ examples at level 1

← C++ typing practice