I love bit manipulation.
If you break up the shift function to separate Left and Right variants, you can drop the text 'right' or 'left' parameter and test, and let AI2 typeblocking help you specify the direction.
Procedure and test blocks are draggable into Blocks Editor,
screen shot not draggable.
P.S. This shift left operator is wrong, in that it does not take into account the 16 bit unsigned data type being shifted left.
There are two schools of thought as to what results from a shift left that overflows the left end:
- The result is undefined, or
- You clip the overflow.
This question can be only answered by examining the original algorithm source and its environment.