Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bitwise

Status
Not open for further replies.

tekbond007

Programmer
Aug 7, 2001
16
IN
i have doubt in bitwise operator

i.e 2 << -4 nad 3 >> -5

i want the output to be expained

 
All I can do here is quote the book:

The result of a shift operation is undefined if the second operand is negative, or if the right operand is greater than or equal to the width in bits of the promoted left operand.

Shifting a negative value to the right yields half the absolute value, rounded down. For example, –253 (binary 11111111 00000011) shifted right one bit produces –127 (binary 11111111 10000001). A positive 253 shifts right to produce +126.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top