The Bit Manipulation Tricks You Need To Know For Coding Interview
The art of bit manipulation is an indispensable skill in the realm of programming, particularly for individuals preparing for technical interviews. The adeptness to directly manipulate bits not only unveils a profound comprehension of how computers process data but also empowers the seamless handling of specific computational tasks; as we all know, computers talk in bits.
· Basic Operations
· Signed and Unsigned Shifting
· Iterating the Bits
· Subtraction by One
∘ Remove the Last Set Bit
∘ Get the Last Set Bit
· Adding By One
· Applications
· Other Tips for Interview
∘ Tip 1
∘ Tip 2
Basic Operations
The basic four bitwise operations include AND (&), OR (|), XOR (^), and NOT (~). Since they are fundamental, I assume we all know them well.