Difference between revisions of "Bit.brshift"
From ComputerCraft Wiki
(Explain that this is an arithmetic, not logical, shift, and add a corresponding example) |
m (Missing template close) |
||
Line 17: | Line 17: | ||
|code=print(bit.brshift(2147483648, 2)) | |code=print(bit.brshift(2147483648, 2)) | ||
|output=3758096384 | |output=3758096384 | ||
+ | }} | ||
}} | }} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] |
Revision as of 18:10, 21 April 2013
Function bit.brshift | |
Shifts a number right arithmetically by a specified number of bits | |
Syntax | bit.brshift(int n, int bits) |
Returns | int the value of n shifted right by bits bits, with the shifted-in bits being equal to the original number’s 31st bit, which is equivalent to ⌊n÷2bits⌋ |
Part of | ComputerCraft |
API | bit |
Examples
Example | |
Shift the number 73 (1001001) right by 2 bits, yielding 18 (10010) | |
Code |
print(bit.brshift(73, 2)) |
Output | 18 |