Difference between revisions of "Bit (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(update deprecated API table too)
Line 49: Line 49:
 
}}
 
}}
  
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
+
{{API table|Bit|image=Grid disk.png|2=
<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]]&nbsp;&nbsp;Bit (API)</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>
+
{{API table/row
 +
|[[bit.tobits]]({{type|number}} n)|{{type|table}} bit_tbl
 +
|Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values.
 +
|odd}}
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|table}} bit_tbl</td>
+
{{API table/row
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[bit.tobits]]({{Type|number}} n)</td>
+
|[[bit.tonumb]]({{type|table}} bit_tbl)|{{type|number}} value
<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>
+
|Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number.
 +
|odd}}
  
<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;">Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number.</td></tr>
+
</table>
+
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 03:08, 25 August 2013

The Bit API is for manipulating numbers using bitwise binary operations.

All of these functions treat the numbers as 32-bit integers, and will raise an error if an input number is greater than 4,294,967,295.

Grid disk.png  Bit (API)
Function Return values Description
bit.blshift(number n, number bits) number value Shifts a number left by a specified number of bits.
bit.brshift(number n, number bits) number value Shifts a number right arithmetically by a specified number of bits.
bit.blogic_rshift(number n, number bits) number value Shifts a number right logically by a specified number of bits.
bit.bxor(number m, number n) number value Computes the bitwise exclusive OR of two numbers.
bit.bor(number m, number n) number value Computes the bitwise inclusive OR of two numbers.
bit.band(number m, number n) number value Computes the bitwise AND of two numbers.
bit.band(number n) number value Computes the bitwise NOT of a numbers.


Deprecated Functions

These functions have been deprecated.
These functions have been removed from ComputerCraft .
Grid disk.png  Bit (API)
Function Return values Description
bit.tobits(number n) table bit_tbl Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values.
bit.tonumb(table bit_tbl) number value Converts an array (numerically-indexed table) of 0 and 1 values representing a number in binary into that number.