#### Revision [20411]

This is an old revision of KeyPgOpShiftLeft made by DkLwikki on 2016-02-10 16:05:33.

### Operator Shl (Shift left)

Shifts the bits of a numeric expression to the left

**Syntax:**

declare operator

declare operator

declare operator

declare operator

**Shl**( byref*lhs*as integer, byref*rhs*as integer ) as integerdeclare operator

**Shl**( byref*lhs*as uinteger, byref*rhs*as uinteger ) as uintegerdeclare operator

**Shl**( byref*lhs*as longint, byref*rhs*as longint ) as longintdeclare operator

**Shl**( byref*lhs*as ulongint, byref*rhs*as ulongint ) as ulongint**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

`being shifted left`*lhs*`number of times.`*rhs***Description:**

**shifts all of the bits in the left-hand side expression (**

`Operator Shl`(Shift left)`) left a number of times specified by the right-hand side expression (`

*lhs*`). Numerically, the result is the same as "`

*rhs*`Cint( lhs * 2 ^ rhs )`". For example, "

`&b0101`" returns the binary number

**Shl**1`&b01010`, and "

`5`" returns

**Shl**1`10`.

Neither of the operands are modified in any way.

If the result is too large to fit inside the result's data type, the leftmost bits are discarded ("shifted out").

The results of this operation are undefined for values of

The results of this operation are undefined for values of

`less than zero, or greater than or equal to the number of bits in the result's data type.`*rhs*
This operator can be overloaded for user-defined types.

**Examples:**

'Double a number

For i As Integer = 0 To 10

Print 5 Shl i, Bin(5 Shl i, 16)

Next i

For i As Integer = 0 To 10

Print 5 Shl i, Bin(5 Shl i, 16)

Next i

Output:

5 0000000000000101 10 0000000000001010 20 0000000000010100 40 0000000000101000 80 0000000001010000 160 0000000010100000 320 0000000101000000 640 0000001010000000 1280 0000010100000000 2560 0000101000000000 5120 0001010000000000

**Dialect Differences:**

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

**Differences from QB:**

- New to FreeBASIC

**See also:**

Back to Arithmetic Operators

Back to Operators