[issue42720] << operator has a bug

2020-12-22 Thread Eric V. Smith
Eric V. Smith added the comment: That's not how they're defined. From https://docs.python.org/3/reference/expressions.html?highlight=left%20shift#shifting-operations "A right shift by n bits is defined as floor division by pow(2,n). A left shift by n bits is defined as multiplication with po

[issue42720] << operator has a bug

2020-12-22 Thread Nandish
Nandish added the comment: I took print(100>>3), I dropped last 3 bits and added value ‘0’ to first 3 bits. Both manual calculation and python result was correct. How can << shit operator and >> shit operator work differently , with different logic ? Thanks Nandish On Wed, Dec 23, 2020 at 12:

[issue42720] << operator has a bug

2020-12-22 Thread Eric V. Smith
Eric V. Smith added the comment: Why do you think the first 3 bits should be dropped? That's not the documented behavior of <<. -- nosy: +eric.smith ___ Python tracker ___ __

[issue42720] << operator has a bug

2020-12-22 Thread Nandish
New submission from Nandish : 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 010, and I converted this to