wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Shift Operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Shift Operators" Watch "Shift Operators" New topic

Shift Operators

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102

I am terribly bad in shift operators. I have to learn shift operators. Can anyone pls help me with any url containing articles on shift operators.

Thanks & Regards,
vinay vishal

Joined: Dec 29, 2006
Posts: 9
Read This Book -> Complete Reference Java-2 or java-5
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Try Corey's TipLine article on bit shifting. See the link at the top of this forum for more of Corey's articles.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Gitesh Ramchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 274
Check this out,

Shift and Bitwise operators are used to manipulate data at bit level.

Shift operatorsBitwise operators

Shift operators should be used only with operands of type int or long, though they can also be used with other integral types. Shift operators always return a result of type INT or LONG.

Positive integer0..0 110012
Negative integer1..1 1100-4

Negative integer1..1 1100-4
Signed right-shift1..1 1110-2
unsigned right-shift0..1 11102147483646
Left-shift1..1 1000-8

With the unsigned right-shift operator (>>> and the left shift operator, the new bits are always set to 0.

The result of ~x will always be the value ((-x) -1)

Hope it helps.

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hello "grr rrr"-

Welcome to JavaRanch.

On your way in you may have missed that we have a JavaRanch Naming Policy for displayed (screen) names. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Since yours "grr rrr", does not conform with it, please take a moment to change it, which you can do right here.

Posters with nonconforming displayed names will be locked out of JavaRanch after a few posts using those names.


(NR) - search tag
I agree. Here's the link: http://aspose.com/file-tools
subject: Shift Operators
jQuery in Action, 3rd edition