LShift Function

Shifts numeric data to the left by a user specified number of bits.

Syntax
LShift(number, shiftBits)

Parameters

number
Specify the integer value to be shifted.
shiftBits
Specify the number of bits (integer from 0 to 31) to shift number to the left.

Return Values
Returns a numeric result which is equal to the value of number after shifting left shiftBits number of bits.

Description
LShift shifts the specified numeric data (number) to the left (toward a higher order digit) by the specified number of bits (shiftBits). The low order bits shifted are replaced by 0.

The simplest explanation for LShift is that it simply returns the result of number * 2 shiftBits.

Note


  • Numeric Data Type:

    The numeric data number may be any valid numeric data type. LShift works with data types: Byte, Double, Int32, Integer, Long, Real, Short, UByte, UInt32, and UShort.


See Also
And, LShift64, Not, Or, RShift, RShift64, Xor

LShift Function Example

Function lshiftst
    Integer i
    Integer num, snum
    num = 1
    For i = 1 to 10
         Print "i =", i
         snum = LShift(num, i)
         Print "The shifted num is ", snum
    Next i
Fend

Some other example results from the LShift instruction from the command window.

> Print LShift(2,2)
8
> Print LShift(5,1)
10
> Print LShift(3,2)
12
>