Operator Shl (Shift Left)
 
Shifts the bits of a numeric expression to the left

Syntax
Usage

result = lhs Shl rhs

Parameters

lhs
The left-hand side expression.
rhs
The right-hand side shift expression.

Return Value

Returns the result of lhs being shifted left rhs number of times.

Description

Operator Shl (Shift left) shifts all of the bits in the left-hand side expression (lhs) left a number of times specified by the right-hand side expression (rhs). This has the effect of multiplying lhs by two for each shift. For example, &b0101 Shl 1 returns the binary number &b01010, and 5 Shl 1 returns 10.

Neither of the operands are modified in any way.

This operator can be overloaded for user-defined types.

Example

'Double a number
Dim i As Integer

For i = 1 To 10
    Print 1 Shl i
Next i
Sleep

Output:
2
4
8
16
32
64
128
256
512
1024


Dialect Differences

  • Not available in the -lang qb dialect unless referenced with the alias __Shl.

Differences from QB

  • New to FreeBASIC

See also