Bitwise Shift Left '<<'
Syntax
Assignment Variable = Variable << Shift_Amount
Overview
Shifts the bits of an integer value to the left a specified number of places. Bits shifted off the left end of a number are lost, and bits shifted into the right end of the number are 0s. Shifting the bits of a value left n number of times also has the effect of unsigned multiplying that number by two to the nth power.
For example 100 << 3 (shift the bits of the decimal number 100 left three places) is equivalent to 100 * 2 ^ 3.
Operands
Variable can be a constant, variable or expression that holds the value to shift. Shift_Amount can be a constant, variable or expression that holds the amount of shifts to perform. Assignment Variable can be any valid variable type.
Example
Device = 18F26K40 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
Dim Wordin as Word
Dim bMyLoop as Byte
Wordin = 0b1111111111111111
For bMyLoop = 1 To 16 ' Repeat with bMyLoop = 1 to 16.
HRsoutLn Bin Wordin << bMyLoop ' Shift variable Wordin left bMyLoop places.
Next
Note.
Bitwise operations are not permissible with floating point constants or variables.
Left shifts are unsigned, regardless of the variable type used.
