0

What is the purpose of shift operators?

24th May 2017, 12:42 AM
Kacy Colledge
Kacy Colledge - avatar
2 Antworten
+ 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 😎)
24th May 2017, 12:56 AM
Rrestoring faith
Rrestoring faith - avatar
+ 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
24th May 2017, 2:08 AM
Eranga
Eranga - avatar