SHL and SHR
Bit Shift Instructions
<expr> SHL <distance>
<expr> SHR <distance>
<expr> expression by
<distance> bits to the left (
SHL) or to the right (
SHR can be replaced by
<< for more legibility.
Use of bitshifting with fixed and float gives undefined results.
INT should be used to convert floating point numbers into integer type numbers before use of the bit shift instructions.
Owing to the nature of moving bits right and left,
SHL n is the equivalent of a multiply by 2n, and
would be the equivalent of an integer division by 2n (destroying any fractional part).
PRINT 2 << 1: REM prints 4 PRINT 16 SHR 2: REM again 4
- This function is not available in Sinclair BASIC.
- The syntax is similar to C's