The operator ~ can flip all of the bits in a variable.
#include <iostream> using namespace std; int main(int argc, char *argv []) { int test = 0x0000000F; cout << hex << ~test; return 0; }