# i>>>32 ??? & i>>>0 and i>>>35

Amit Tyagi

Ranch Hand

Posts: 52

Sudhir Bangera

Ranch Hand

Posts: 50

Amit Tyagi

Ranch Hand

Posts: 52

ranga akarapu

Greenhorn

Posts: 3

posted 15 years ago

to do the above shift operation

step1: you calculate the binary value of 35 i.e 0100011

step2: find the two's compliment of it i.e.it becomes 1011100

step3: then add 1 to it i.e. it becomes 1001101

step4: now shift it by 3 places to its right

note: in first shift itselt it looses its sign

step5: recalculate to decimal form

I hope answer is inline for what u r looking

bye ranga..

step1: you calculate the binary value of 35 i.e 0100011

step2: find the two's compliment of it i.e.it becomes 1011100

step3: then add 1 to it i.e. it becomes 1001101

step4: now shift it by 3 places to its right

note: in first shift itselt it looses its sign

step5: recalculate to decimal form

I hope answer is inline for what u r looking

bye ranga..

Prasad Ballari

Ranch Hand

Posts: 149

Jane Griscti

Ranch Hand

Posts: 3141

posted 15 years ago

Hi Prasad,

It's easier to work with the formula equivalents for the shift operators.

<pre>

Left-shift: 16<<5 equivalent to 16 * 2<sup>5</sup><br /> Right-shift: 16>>5 equivalent to 16 / 2<sup>5</sup>

</pre>

For the unsigned right shift operator >>>, if the number is positive, the result is the same as the right-shift operator. If the number is negative the equivalent formula is:

<pre>

-16 >>> 5 equiv to (16>>5) + ( 2<<~5)

</pre>

Hope that helps.

------------------

Jane

[This message has been edited by Jane Griscti (edited October 29, 2000).]

It's easier to work with the formula equivalents for the shift operators.

<pre>

Left-shift: 16<<5 equivalent to 16 * 2<sup>5</sup><br /> Right-shift: 16>>5 equivalent to 16 / 2<sup>5</sup>

</pre>

For the unsigned right shift operator >>>, if the number is positive, the result is the same as the right-shift operator. If the number is negative the equivalent formula is:

<pre>

-16 >>> 5 equiv to (16>>5) + ( 2<<~5)

</pre>

Hope that helps.

------------------

Jane

[This message has been edited by Jane Griscti (edited October 29, 2000).]

Jane Griscti

SCJP, Co-author Mike Meyers' Java 2 Certification Passport