int a = 17 (=10001)
int b=5 (101)
a&b 1 bitwise AND
a|b 21 bitwise OR
a^b 20 XOR (16+4) “just one”
a&&b 1 logical AND
a||b 1 logical OR
-b -5 minus b
~b -6 ?
~(~a) 17 ?
!b 0 logical “NOT B”
!(!a)) 1 logical “NOT NOT A”
a=b 0 “a==b?”
a=’A’ 65 ?
a|’@’ 64 ?
Can you please help me explain the parts where the ? is.
The “~” flips all the bits, and negative numbers are represented using something called 2s complement. The -6 is just what happens when you flip all the bits of “5”: you get a different bitpattern, which is the same bits as “-6” in 2s complement.
Similar. Flip all the bits, then flip all the bits again, and what do you get? The same as before.
Internally, characters are represented by numbers, just like everything else in a computer. Virtually all these number<->character tables in use today are based on ASCII, and ‘A’ just happens to have the number 65 in the ASCII table.
That doesn’t make sense. ‘@’ is 64 (ASCII, again), which is hex 0x40. 0x40 | 17 should be 81.