Difference between revisions of "Bit.brshift"

From ComputerCraft Wiki
Jump to: navigation, search
m (Moved to CAT:APIFunctions)
m (Int linking fix.)
Line 4: Line 4:
 
|args=[[int (type)|int]] n, [[int (type)|int]] bits
 
|args=[[int (type)|int]] n, [[int (type)|int]] bits
 
|api=bit
 
|api=bit
|returns=[[int]] the value of <var>n</var> shifted right by <var>bits</var> bits, which is equivalent to ⌊<var>n</var>÷2<sup><var>bits</var></sup>⌋
+
|returns=[[int (type)|int]] the value of <var>n</var> shifted right by <var>bits</var> bits, which is equivalent to ⌊<var>n</var>÷2<sup><var>bits</var></sup>⌋
 
|addon=ComputerCraft
 
|addon=ComputerCraft
 
|desc=Shifts a number right by a specified number of bits
 
|desc=Shifts a number right by a specified number of bits

Revision as of 18:35, 30 November 2012


Grid Redstone.png  Function bit.brshift
Shifts a number right by a specified number of bits
Syntax bit.brshift(int n, int bits)
Returns int the value of n shifted right by bits bits, which is equivalent to ⌊n÷2bits
Part of ComputerCraft
API bit

Examples

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