I have been trying to understand which representation is used by python for storing negative integers (1s complement, 2s complement or signed bit representation). For that, I tried out these functions
>>> bin(-10)
'-0b1010'
>>> bin(10)
'0b1010'
>>> format(10,'b')
'1010'
>>> format(-10,'b')
'-1010'
>>> format(-10,'16b')
' -1010'
>>> format(-10,'32b')
' -1010'
>>> format(-10,'64b')
' -1010'
However, -1010
is not any of the above 3 representations (how is it storing the - symbol ?). The representation here I am getting is just -
in front of the standard binary representation of the positive counterpart. So, how can I know the actual representation?