I want to do a bitwise not in Python, but withouth taking care of the sign, as C would do. For example:
>>> x = 4
>>> y = ~x
>>> bin(x)
'0b100'
>>> bin(y)
'0b101'
In the above code, y
is 0b101
, but I want it to be 0b011
, literally the bitwise not applied to number 4
. How can I do this?