Difference between revisions of "Bit (API)"
From ComputerCraft Wiki
(Pull out removed functions and add missing function) |
(Make table include return types and make types use type template) |
||
Line 2: | Line 2: | ||
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | <table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | ||
− | <tr><td colspan=" | + | <tr><td colspan="3" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">[[File:Grid_disk.png|24px]] Bit (API)</td></tr> |
− | <tr><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: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blshift]]( | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blshift]]({{Type|int}} n, {{Type|int}} 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: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.brshift]]( | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.brshift]]({{Type|int}} n, {{Type|int}} 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;">[[bit.blogic_rshift]]( | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.blogic_rshift]]({{Type|int}} n, {{Type|int}} 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;">[[bit.bxor]]( | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bxor]]({{Type|int}} m, {{Type|int}} 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;">[[bit.bor]]( | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bor]]({{Type|int}} m, {{Type|int}} 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;">[[bit.band]]( | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.band]]({{Type|int}} m, {{Type|int}} 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;">[[bit.bnot]]( | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} value</td> |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.bnot]]({{Type|int}} 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 31: | Line 38: | ||
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | <table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | ||
− | <tr><td colspan=" | + | <tr><td colspan="3" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">[[File:Grid_disk.png|24px]] Bit (API)</td></tr> |
− | <tr><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;">[[bit.tobits]]( | + | <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|int}} 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;">[[bit.tonumb]]( | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int}} 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;">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> | ||
</table> | </table> | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 14:09, 22 April 2013
The Bit API is for manipulating numbers using bitwise binary operations.
Bit (API) | ||
Return | Method name | Description |
int value | bit.blshift(int n, int bits) | Shifts a number left by a specified number of bits. |
int value | bit.brshift(int n, int bits) | Shifts a number right arithmetically by a specified number of bits. |
int value | bit.blogic_rshift(int n, int bits) | Shifts a number right logically by a specified number of bits. |
int value | bit.bxor(int m, int n) | Computes the bitwise exclusive OR of two numbers. |
int value | bit.bor(int m, int n) | Computes the bitwise inclusive OR of two numbers. |
int value | bit.band(int m, int n) | Computes the bitwise AND of two numbers. |
int value | bit.bnot(int n) | Computes the bitwise NOT of a number. |
The following functions used to exist in this API but no longer do:
Bit (API) | ||
Return | Method name | Description |
table bit_tbl | bit.tobits(int n) | Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values. |
int 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. |