Author Nandish
Recipients Nandish
Date 2020-12-22.19:00:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I verified the following on both Python 2.7 and Python 3.8

I did print(100<<3) Converting 100 to Binary gives 1100100. What I did is I droped the first 3 bits and added 3 bits with the value '0' at the end. So it should result as 0100000, and I converted this to Decimal and the answer was 32.

For my suprise when I executed print(100<<3) the answer was 800. I was puzzled. I converted 800 to Binary to check whats going on. And this is what I got 1100100000.

If you see how 800 was Python answer, they did not shift or drop the first 3 bits but they added value '0' to last 3 bits.

Where as print(100>>3) , worked perfect. I did manual calculation and cheked the print result from python. It worked correctly. Dropped last 3 bits and added value '0' to first 3 bits.

Looks like (100<<3) , left shift operator has a bug on Python.
Date User Action Args
2020-12-22 19:00:23Nandishsetrecipients: + Nandish
2020-12-22 19:00:22Nandishsetmessageid: <>
2020-12-22 19:00:22Nandishlinkissue42720 messages
2020-12-22 19:00:22Nandishcreate