Revision [14401]

This is an old revision of KeyPgOpShiftLeft made by CountingPine on 2009-08-29 21:55:44.


Operator Shl (Shift left)

Shifts the bits of a numeric expression to the left

result = lhs Shl rhs

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

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

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.

'Double a number
For i As Integer = 0 To 10
    Print 5 Shl i, Bin(5 Shl i, 16)
Next i

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

Dialect Differences:
Differences from QB:
See also:
Back to Arithmetic Operators
Back to Operators
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode