Shl Keyword
The shl
operator performs a left shift of an
integer Value
by
Bits
bit positions. Vacated bits are
filled in on the right with zero bits.
The Bits
operand is interpreted as an
unsigned integer, modulo the size of the
Value
. That is, if
Value
is a LongInt
,
Bits
is interpreted modulo 32, and if
Value
has type Int64
,
Bits
is interpreted modulo 64. In other
words, only the least significant few bits of
Bits
are used to determine the shift
amount.
Remember that the size of the Integer
and
Cardinal
types can change with new versions of
Delphi. Use the fixed-size types if you need a specific number of
bits, such as 32 for LongInt
and
LongWord
.
Do not use the shl
operator instead of multiplying
by a power of two. If you mean multiplication, you should write
multiplication. The shl
operator does not check
for overflow errors. Let Delphi’s compiler decide the best
instruction to use.