bit.blogic rshift

From ComputerCraft Wiki
Revision as of 18:09, 21 April 2013 by Hawk777 (Talk | contribs) (New page for new function)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

{{Function |name=bit.blogic_rshift |args=int n, int bits |api=bit |returns=int the value of n shifted right by bits bits, with the shifted-in bits all being zero, which is equivalent to ⌊n÷2bits⌋ for nonnegative numbers |addon=ComputerCraft |desc=Shifts a number right logically by a specified number of bits |examples=

Grid paper.png  Example
Shift the number 73 (1001001) right by 2 bits, yielding 18 (10010)
Code
print(bit.blogic_rshift(73, 2))
Output 18



Grid paper.png  Example
Shift the number 2,147,483,648 (10000000000000000000000000000000) right by 2 bits, yielding 536,870,912 (00100000000000000000000000000000)
Code
print(bit.blogic_rshift(2147483648, 2))
Output 536870912