Bitwise Operations -- Arithmetic Operations..

Posted by RBA on Stack Overflow See other posts from Stack Overflow or by RBA
Published on 2010-05-10T06:33:16Z Indexed on 2010/05/10 6:34 UTC
Read the original article Hit count: 358

Filed under:
|

Hi,

Can you please explain the below lines, with some good examples.

A left arithmetic shift by n is equivalent to multiplying by 2n (provided the value does not overflow),

while

a right arithmetic shift by n of a two's complement value is equivalent to dividing by 2n(2 to the power n) and rounding toward negative infinity. If the binary number is treated as ones' complement, then the same right-shift operation results in division by 2n and rounding toward zero.

Thankx..

© Stack Overflow or respective owner

Related posts about c

    Related posts about bitwise-operations