1

To represent a negative number in binary form we can use 0 or 1 as an additional digit in binary number but python return negative sign for negative number using bin function. Why it is not returning negative binary number using 0 and 1, and how can we get binary form of negative number without neagtive sign using Python:

>>> bin(11)
'0b1011'
>>> bin(-11)
'-0b1011'
Timus
  • 10,974
  • 5
  • 14
  • 28
  • You mean this: https://stackoverflow.com/questions/12946116/twos-complement-binary-in-python – Pena86 Oct 15 '21 at 11:16
  • Please [DO NOT post images of code, data, error messages, etc.](https://stackoverflow.com/help/how-to-ask). – Timus Oct 15 '21 at 11:26

0 Answers0