Flipping bits

  • + 0 comments
    public static long flippingBits(long n) {
            // Create a mask with all bits set to 1
            long mask = 0xFFFFFFFFL; 
    
            // Flip all bits using XOR operation
            return n ^ mask;
        }