Today we went over Bit String Flicking. There are bitwise operations: OR (|), AND (&), XOR (^), and NOT (~). And there are shifting operations: LSHIFT, RSHIFT, LCIRC, and RCIRC. The order of precedence for these operations can be found here.
HW answers:
~1 = 0
~01011 = 10100
10010 | 11010 = 11010
10001 & 01110 = 00000
And I got a bonus question... can anyone find a formula/ pattern for the XOR of all numbers from 0 to x for any positive x? (without searching it up of course).
Solution
{x,1,x+1,0}[x%4]