Difference between revisions of "Bit.tobits"

From ComputerCraft Wiki
Jump to: navigation, search
m (Changed nonexistent type int to type number.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
 +
 +
{{Deprecated
 +
|type=This function
 +
}}
 +
 
{{Function
 
{{Function
 
|name=bit.tobits
 
|name=bit.tobits
|args=[[int (type)|int]] n
+
|args={{Type|number}} n
 
|api=bit
 
|api=bit
|returns=[[table]] the bits making up the value <var>n</var>, with entries up to the most-significant 1 bit in <var>n</var>
+
|returns={{Type|table}} the bits making up the value <var>n</var>, with entries up to the most-significant 1 bit in <var>n</var>
 
|addon=ComputerCraft
 
|addon=ComputerCraft
 
|desc=Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values (the inverse of [[bit.tonumb]])
 
|desc=Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values (the inverse of [[bit.tonumb]])
Line 11: Line 16:
 
|desc=Convert the number 18 into its binary representation (10010)
 
|desc=Convert the number 18 into its binary representation (10010)
 
|code=for k, v in pairs(bit.tobits(18)) do print(k, ", ", v) end
 
|code=for k, v in pairs(bit.tobits(18)) do print(k, ", ", v) end
|output=1, 0<br>2, 1<br>3, 0<br>4, 1<br>5, 0
+
|output=1, 0<br>2, 1<br>3, 0<br>4, 0<br>5, 1
 
}}
 
}}
 
}}
 
}}
 
As of ComputerCraft 1.42 the bit library has moved to Java code, and as such this function is no longer required or included.
 
As of ComputerCraft 1.42 the bit library has moved to Java code, and as such this function is no longer required or included.
 +
 +
[[Category:API_Functions]]

Latest revision as of 01:52, 12 July 2013


This function has been deprecated.
This function has been removed from ComputerCraft .


Grid Redstone.png  Function bit.tobits
Converts a number to an array (numerically-indexed table) containing the corresponding binary bit values (the inverse of bit.tonumb)
Syntax bit.tobits(number n)
Returns table the bits making up the value n, with entries up to the most-significant 1 bit in n
Part of ComputerCraft
API bit

Examples

Grid paper.png  Example
Convert the number 18 into its binary representation (10010)
Code
for k, v in pairs(bit.tobits(18)) do print(k, ", ", v) end
Output 1, 0
2, 1
3, 0
4, 0
5, 1


As of ComputerCraft 1.42 the bit library has moved to Java code, and as such this function is no longer required or included.