Re: [BangPypers] Need help understanding -9 >> 1

2012-07-02 Thread steve
Hi, On 06/29/2012 04:03 PM, Anand Chitipothu wrote: > On Fri, Jun 29, 2012 at 3:40 PM, Varun Narang wrote: >> Hi all, >> >> I need some help understanding the right shift operation on -9. To my >> understanding, it's represented as -0b1001, Now, if I shift it one place to >> right, it should give

Re: [BangPypers] Need help understanding -9 >> 1

2012-06-29 Thread Anand Chitipothu
On Fri, Jun 29, 2012 at 3:40 PM, Varun Narang wrote: > Hi all, > > I need some help understanding the right shift operation on -9. To my > understanding, it's represented as -0b1001, Now, if I shift it one place to > right, it should give me -0b0100, which is decimal equivalent of 4. but > running

Re: [BangPypers] Need help understanding -9 >> 1

2012-06-29 Thread Navin Kabra
Varun Narang 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 0xfff7. When you shift it to the right, a '1' is shifted

[BangPypers] Need help understanding -9 >> 1

2012-06-29 Thread Varun Narang
Hi all, I need some help understanding the right shift operation on -9. To my understanding, it's represented as -0b1001, Now, if I shift it one place to right, it should give me -0b0100, which is decimal equivalent of 4. but running this on python console gives me -5. Please help me out here. T