This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello guys one question has been hovering me from the beginning of my java learning career .... why do we use shift operators i have been referring to many books and googled it online still not sure about the usage and pondering about its working ....can anybody please elucidate me ???
1. Graphics. Shifting is needed to create bit patterns -- or to create masks that can be used to set (OR) or clear (AND) dots.
2. Networking. Shifting is need to create network masks. The masks needed to set or clear bits specified in a protocol.
3. Security. Encryption needs this a lot.
Less obvious use... Some mathematical operations are faster with shifting. With modern processors, this is not true anymore, as they are loaded with instructions that can do practically anything needed by math.
Now, all of this may be moot, as Java has libraries that does all of this for you. In fact, most new developers rarely, if ever, encounter a need to use the shifting (or bitwise) operators.... which is a shame.