shiftRight
Purpose
Bit shift right operator >>
Description
Shift all of the bits in a binary number to the right the specified number of times. The new leftmost bits are set to zero
Syntax
result = number1 >> number2
Arguments
number1 first binary number
number2 number of bits to shift
result resulting number with the bits of number1 shifted right 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