Flip all bits in an integer Technology Community › Category: Bit Manipulation › Flip all bits in an integer 0 Vote Up Vote Down VietMX Staff asked 4 years ago Problem I have to flip all bits in a binary representation of an integer. Given: 10101 The output should be 01010 What is the bitwise operator to accomplish this when used with an integer? Simply use the bitwise not operator ~. int flipBits(int n) { return ~n; }