Difference between revisions of "Bit (API)"
From ComputerCraft Wiki
(Now perhaps jesusthekiller won't submit false bugreports.) |
m (Int -> {{type|number}}) |
||
Line 6: | Line 6: | ||
<tr><td style="width: 100px; background: #E0E0E0; padding: .4em; font-weight:bold;">Return</td><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | <tr><td style="width: 100px; background: #E0E0E0; padding: .4em; font-weight:bold;">Return</td><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blshift]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blshift]]({{Type|number}} n, {{Type|number}} bits)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number left by a specified number of bits.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number left by a specified number of bits.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.brshift]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.brshift]]({{Type|number}} n, {{Type|number}} bits)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number right arithmetically by a specified number of bits.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number right arithmetically by a specified number of bits.</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blogic_rshift]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blogic_rshift]]({{Type|number}} n, {{Type|number}} bits)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number right logically by a specified number of bits.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Shifts a number right logically by a specified number of bits.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bxor]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bxor]]({{Type|number}} m, {{Type|number}} n)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise exclusive OR of two numbers.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise exclusive OR of two numbers.</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bor]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bor]]({{Type|number}} m, {{Type|number}} n)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise inclusive OR of two numbers.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise inclusive OR of two numbers.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.band]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.band]]({{Type|number}} m, {{Type|number}} n)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise AND of two numbers.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise AND of two numbers.</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bnot]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bnot]]({{Type|number}} n)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise NOT of a number.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Computes the bitwise NOT of a number.</td></tr> | ||
</table> | </table> | ||
Line 48: | Line 48: | ||
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|table}} bit_tbl</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|table}} bit_tbl</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.tobits]]({{Type| | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.tobits]]({{Type|number}} n)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type| | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|number}} value</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.tonumb]]({{Type|table}} bit_tbl)</td> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.tonumb]]({{Type|table}} bit_tbl)</td> | ||
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number.</td></tr> |
Revision as of 00:52, 12 July 2013
The Bit API is for manipulating numbers using bitwise binary operations.
Bit (API) | ||
Return | Method name | Description |
number value | bit.blshift(number n, number bits) | Shifts a number left by a specified number of bits. |
number value | bit.brshift(number n, number bits) | Shifts a number right arithmetically by a specified number of bits. |
number value | bit.blogic_rshift(number n, number bits) | Shifts a number right logically by a specified number of bits. |
number value | bit.bxor(number m, number n) | Computes the bitwise exclusive OR of two numbers. |
number value | bit.bor(number m, number n) | Computes the bitwise inclusive OR of two numbers. |
number value | bit.band(number m, number n) | Computes the bitwise AND of two numbers. |
number value | bit.bnot(number n) | Computes the bitwise NOT of a number. |
Deprecated Functions
These functions have been deprecated. These functions have been removed from ComputerCraft .
|
Bit (API) | ||
Return | Method name | Description |
table bit_tbl | bit.tobits(number n) | Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values. |
number value | bit.tonumb(table bit_tbl) | Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number. |