0
What is the purpose of shift operators?
2 Respostas
+ 4
They are the shift bit operators.
For example:
9 in binary is:
1001
If i said 9 >> 1
It would move the bits over 1 place to the right.
So now it would be:
0100
Or, 4
Since 4 in binary is 100.
Hence, 9 >> 1 = 4
While 4 << 1 = 8.
(Try to find out why 😎)
+ 2
Faith mentioned the theory part of bit-shift. If u r interested in real world use cases of bitwise, best/common one would be data compression and encryption.
follow the link for for info:
https://stackoverflow.com/questions/2096916/real-world-use-cases-of-bitwise-operators
More on bit-shift:
https://stackoverflow.com/questions/141525/what-are-bitwise-shift-bit-shift-operators-and-how-do-they-work