bit32.lshift

From ComputerCraft
Jump to navigation Jump to search

bit32.lshift
Function
Syntax
bit32.lshift()
Returns number shifted
API bit32
Source Lua (source)

Bitwise left-shift. When called, shifts all bits in a number the specified amount to the left. For example, 3 is 11 in binary. Shifting it two bits to the left makes it twelve (1100). A left-shift is also equivalent to number * 2shift.

ExampleExampleShifting bits
Shifting ten (1010) 2 bits to the left. This should output 40, as 1010 becomes 101000
Code
local ten = 10
print(bit32.lshift(ten, 2))
Output 40