2 ms·
XOR = Addition (without carry) Left Shift = Multiply by 2 ^ n (without checking for overflow [1]). Right Shift = Divide by 2 ^ n (without rounding) As all da
by valarauca1 12y ago
XOR = Addition (without carry)
Left Shift = Multiply by 2 ^ n (without checking for overflow [1]).
Right Shift = Divide by 2 ^ n (without rounding)
As all data in stored, and processed in binary representation right/left shifts are fun hacks we gain from this system. Moving an entire integer 1 space left/right will double/halve its value! Its also very easy to replicate this operation in hardware.
Absolute Beginner Guide on S/O https://stackoverflow.com/questions/141525/absolute-beginners-guide-to-bit-shifting https://stackoverflow.com/questions/141525/absolute-beginner...
[1] Sometimes, it depends, its actually complicated, depends on language, machine, etc.