I tried the following command line in python
In[1]: ~(True ^ False)
and it returned :
Out[1]: -2
Could someone explain this to me please?
Thanks in advance
I tried the following command line in python
In[1]: ~(True ^ False)
and it returned :
Out[1]: -2
Could someone explain this to me please?
Thanks in advance
It's because of how python handles booleans:
True is represented as 1, (See True==1)
False is represented as 0. (See False==0)
Without syntactic sugar and abstractions:
x=~(1 ^ 0)
x=~1
x=-2