Difference between revisions of "Bit (API)"
From ComputerCraft Wiki
(added function links) |
(Add descriptions) |
||
Line 7: | Line 7: | ||
|- | |- | ||
|[[bit.tobits]](n) | |[[bit.tobits]](n) | ||
− | | | + | |Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values |
|- | |- | ||
|[[bit.blshift]](n, bits) | |[[bit.blshift]](n, bits) | ||
− | | | + | |Shifts a number left by a specified number of bits |
|- | |- | ||
|[[bit.brshift]](n, bits) | |[[bit.brshift]](n, bits) | ||
− | | | + | |Shifts a number right by a specified number of bits |
|- | |- | ||
|[[bit.bxor]](m, n) | |[[bit.bxor]](m, n) | ||
− | | | + | |Computes the bitwise exclusive OR of two numbers |
|- | |- | ||
|[[bit.bor]](m, n) | |[[bit.bor]](m, n) | ||
− | | | + | |Computes the bitwise inclusive OR of two numbers |
|- | |- | ||
|[[bit.band]](m, n) | |[[bit.band]](m, n) | ||
− | | | + | |Computes the bitwise AND of two numbers |
|- | |- | ||
|[[bit.bnot]](n) | |[[bit.bnot]](n) | ||
− | | | + | |Computes the bitwise NOT of a number |
|- | |- | ||
|[[bit.tonumb]](bit_tbl) | |[[bit.tonumb]](bit_tbl) | ||
− | | | + | |Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number |
|} | |} | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 22:29, 11 March 2012
The Bit API is for manipulating bits of variables.
A list of functions:
Method name | Description |
---|---|
bit.tobits(n) | Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values |
bit.blshift(n, bits) | Shifts a number left by a specified number of bits |
bit.brshift(n, bits) | Shifts a number right by a specified number of bits |
bit.bxor(m, n) | Computes the bitwise exclusive OR of two numbers |
bit.bor(m, n) | Computes the bitwise inclusive OR of two numbers |
bit.band(m, n) | Computes the bitwise AND of two numbers |
bit.bnot(n) | Computes the bitwise NOT of a number |
bit.tonumb(bit_tbl) | Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number |