File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "shift operators" Watch "shift operators" New topic

shift operators

Richa Jeetah

Joined: Sep 27, 2001
Posts: 29
I know how each works...but i have some difficulty in calculating the values when given to actually solve a few examples.
whats the easiest way to calculate the answers for these operaators.
i read somewhere that
x << y can be interpreted as x*2^y
and x>>y as x/y ^2
how does it work ??
when i tried it ..... it gave diff results.
whats the best way to do it ??
if given : 8>>3
i try to convert it to binary and then perform the operation and convert it back..
it fine if the number is low...
but i fail to apply the same when given
24>>4 or 33>> 4 ... etc
Please Help !
Vin Kris
Ranch Hand

Joined: Jun 17, 2002
Posts: 154
Hi Richa, check out these....
Richa Jeetah

Joined: Sep 27, 2001
Posts: 29
it helped
I agree. Here's the link:
subject: shift operators
It's not a secret anymore!