I got stuck with the following Python code
>>> a = 0xff
>>> b = 1 << 8
>>> ~a & ~b
-512
Why is it -512? In binary notation it should look like this:
a 0 1111 1111 -> 255
b 01 0000 0000 -> 256
~a 1 0000 0000 -> -256
~b 10 1111 1111 -> -257
~a&~b 00 0000 0000 -> 0
I expected 0 as with signed int in C:
signed int a = 0xff;
signed int b = 1 << 8;
signed int k = ~a & ~b;
Any help?