SHL and SHR
Bit Shift Instructions
Syntax
Bit shifts <expr>
expression by <distance>
bits to the left (SHL
) or to the right (SHR
).
SHR
can be replaced by >>
and SHL
by <<
for more legibility.
The uByte
, Byte
, uInteger
, Integer
, uLong
or Long
.
Use of bitshifting with fixed and float gives undefined results.
CAST
or 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 SHR
would be the equivalent of an integer division by 2n (destroying any fractional part).
Examples
Remarks
- This function is not available in Sinclair BASIC.
- The syntax is similar to C's
<<
and>>
operators.