shiftLeft
Purpose
Bit shift left operator <<
Description
Shift all of the bits in a binary number to the left the specified number of times. The new rightmost bits are set to zero. Bitshift left has the effect of multipling the value of the binary number by 2
Syntax
result = number1 << number2
Arguments
number1 first binary number
number2 number of bits to shift
result resulting number with the bits of number1 shifted left number2 times
Example
loop
textsize( 50 )
byte1 = 123
byte2 = 234
printAt( 0, 0, "byte1 = ", bin2str( byte1 ) )
printAt( 0, 1, "byte2 = ", bin2str( byte2 ) )
printAt( 0, 2, "byte1 << 1 = ", bin2str( byte1 << 1 ) )
update()
repeat
function bin2str( byte )
result = ""
for i = 0 to 8 loop
bit = byte & 1
if bit then
result = "1" + result
else
result = "0" + result
endIf
byte = byte >> 1
repeat
return result
Associated Commands