Expand/Shrink

bits_to_int

Definition: atom a = bits_to_int(sequence s)
Description: Convert a sequence of binary 1s and 0s into a positive number. The least-significant bit is s[1].
pwa/p2js: Supported.
Comments: If you print s the bits will appear in "reverse" order, but it is convenient to have increasing subscripts access bits of increasing significance.
Example:
a = bits_to_int({1,1,1,0,1})
-- a is 23 (binary 0b10111, hex #17)
Implementation: See builtins\machine.e (an autoinclude) for details of the actual implementation.
See Also: int_to_bits, sequence operations