Ive been a dev for over 2 decades but I still cant grok bitwise operators - anyone have a reference that may help with that?
For example left shift by 1 on this 8 bit number (decimal is 32)
00100000
you just shift all the numbers to the left
01000000
--------
There's some wrapping behavior of course. Like what happens if you left shift 3 here? If it's an unsigned 8 bit number the 1 would teleport to the right side.
00000001
--------
the logical operators work like this (read downwards)
00010000 AND
00010000 =
00010000
--------
00001000 AND
00010000 =
00000000
--------
00001000 OR
00010000 =
00011000
With this in mind, I found it to be a good exercise to implement common bitwise operators that work on fixed length strings with some tests against the real binary operators in your favorite language.