bit32.rshift
Bitwise right-shift. When called, shifts all bits in a number the specified amount to the right. For example, twelve is 1100 in binary. Shifting it two bits to the right makes it 3 (11). A right-shift is also equivalent to number / 2shift.
|
|||
Shifting ten (1010) 2 bits to the left. This should output 2, as 1010 becomes 10 (the last bit is dropped.) | |||
Code | <nowiki>
local ten = 10
print(bit32.rshift(ten, 2))
</nowiki>
|
||
Output | 2 |
Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Lua |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CC:Tweaked |
|
bit32.rshift Function | |
---|---|
Syntax bit32.rshift(
| |
Returns | number shifted |
API | bit32 |
Source | Lua (source) |
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.