Python representation of negative integers
问题 >>> x = -4 >>> print("{} {:b}".format(x, x)) -4 -100 >>> mask = 0xFFFFFFFF >>> print("{} {:b}".format(x & mask, x & mask)) 4294967292 11111111111111111111111111111100 >>> >>> x = 0b11111111111111111111111111111100 >>> print("{} {:b}".format(x, x)) 4294967292 11111111111111111111111111111100 >>> print("{} {:b}".format(~(x ^ mask), ~(x ^ mask))) -4 -100 I am having trouble figuring out how Python represents negative integers, and therefore how bit operations work. It is my understanding that