I saw this in some JS code:
index = [
ascii[0] >> 2,
((ascii[0] & 3) << 4) | ascii[1] >> 4,
((ascii[1] & 15) << 2) | ascii[2] >> 6,
ascii[2] & 63
];
I’d quite like to know what a lot of this means. Specifically “>>”, a single pipe “|” and the “&” symbol on the last line?
Much appreciated!
x >> ymeans to shift the bits ofxbyyplaces to the right (<<to the left).x | ymeans to compare the bits ofxandy, putting a1in each bit if eitherxoryhas a1in that position.x & yis the same as|, except that the result is1if BOTHxandyhave a1.Examples:
For more information, search Google for “bitwise operators”.