Difference between revisions of "Bit (API)"
From ComputerCraft Wiki
m (→Methods: type listing inconsistencie fix. Bleh.) |
(Number (type) [gone] -> int (type)) |
||
Line 6: | Line 6: | ||
!style="background:#EEE" width="*"|Description | !style="background:#EEE" width="*"|Description | ||
|- | |- | ||
− | |[[bit.tobits]]([[ | + | |[[bit.tobits]]([[int (type)|int]] n) |
|Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values | |Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values | ||
|- | |- | ||
− | |[[bit.blshift]]([[ | + | |[[bit.blshift]]([[int (type)|int]] n, [[int (type)|int]] bits) |
|Shifts a number left by a specified number of bits | |Shifts a number left by a specified number of bits | ||
|- | |- | ||
− | |[[bit.brshift]]([[ | + | |[[bit.brshift]]([[int (type)|int]] n, [[int (type)|int]] bits) |
|Shifts a number right by a specified number of bits | |Shifts a number right by a specified number of bits | ||
|- | |- | ||
− | |[[bit.bxor]]([[ | + | |[[bit.bxor]]([[int (type)|int]] m, [[int (type)|int]] n) |
|Computes the bitwise exclusive OR of two numbers | |Computes the bitwise exclusive OR of two numbers | ||
|- | |- | ||
− | |[[bit.bor]]([[ | + | |[[bit.bor]]([[int (type)|int]] m, [[int (type)|int]] n) |
|Computes the bitwise inclusive OR of two numbers | |Computes the bitwise inclusive OR of two numbers | ||
|- | |- | ||
− | |[[bit.band]]([[ | + | |[[bit.band]]([[int (type)|int]] m, [[int (type)|int]] n) |
|Computes the bitwise AND of two numbers | |Computes the bitwise AND of two numbers | ||
|- | |- | ||
− | |[[bit.bnot]]([[ | + | |[[bit.bnot]]([[int (type)|int]] n) |
|Computes the bitwise NOT of a number | |Computes the bitwise NOT of a number | ||
|- | |- |
Revision as of 18:52, 30 November 2012
The Bit API is for manipulating numbers using bitwise binary operations.
Methods
Method name | Description |
---|---|
bit.tobits(int n) | Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values |
bit.blshift(int n, int bits) | Shifts a number left by a specified number of bits |
bit.brshift(int n, int bits) | Shifts a number right by a specified number of bits |
bit.bxor(int m, int n) | Computes the bitwise exclusive OR of two numbers |
bit.bor(int m, int n) | Computes the bitwise inclusive OR of two numbers |
bit.band(int m, int n) | Computes the bitwise AND of two numbers |
bit.bnot(int n) | Computes the bitwise NOT of a number |
bit.tonumb(table bit_tbl) | Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number |