Why would we want to change bit strings with bitwise operators?


#1

Question

Why would we want to change bit strings with bitwise operators?

Answer

The use cases for bit strings are far and wide, but they’re super common in networking problems. Without going into any particular example, a general use of bit strings, including flipping each bit, is to check the output of a bit string compared with another bit string to perform some action for each bit.
For example, if we compare two bit strings and see that the result is 0101 0000, that might tell your program to perform a particular action. It’s a very powerful tool to have because with just those 8 bits, we can have a total of 2^8 possible operation codes!


FAQ: Learn Python - Introduction to Bitwise Operators - See? This is NOT That Hard!