[BangPypers] Need help understanding -9 >> 1

Navin Kabra navin.kabra at gmail.com
Fri Jun 29 12:23:23 CEST 2012

Varun Narang <varunarang at gmail.com> writes:
> I need some help understanding the right shift operation on -9. To my
> understanding, it's represented as -0b1001, 

No. Integers are represented using 2s complement integers. So -9 will
actually be represented by 0xfffffff7. When you shift it to the right, a
'1' is shifted into the empty slot on the left. S you get: 0xfffffffb
which is -5. 

More information about the BangPypers mailing list