bit.tonumb

From ComputerCraft Wiki
Revision as of 23:08, 11 March 2012 by Hawk777 (Talk | contribs) (Create page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Grid Redstone.png  Function bit.tonumb
Converts an array (numerically-indexed table) containing binary bit values to a number (the inverse of bit.tobits)
Syntax bit.tonumb(table bit_tbl)
Returns int the number resulting from the conversion of bit_tbl from binary
Part of ComputerCraft
API bit

Examples

Grid paper.png  Example
Convert the binary representation 10010 into its corresponding value, 18
Code
t = {}
t[1] = 0
t[2] = 1
t[3] = 0
t[4] = 0
t[5] = 1
print(bit.tonumb(t))
Output 18