updating oE bits_to_int


include convert.e 
namespace convert 
public function bits_to_int(sequence bits) 

converts a sequence of bits to an atom that has no fractional part.

  1. bits : the sequence to convert.

A positive atom, whose machine representation was given by bits.


An element in bits can be any atom. If nonzero, it counts for 1, else for 0.

The first elements in bits represent the bits with the least weight in the returned value. Only the 52 last bits will matter, as the PC hardware cannot hold an integer with more digits than this.

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 1:
a = bits_to_int({1,1,1,0,1}) 
-- a is 23 (binary 10111) 
See Also:

bytes_to_int, int_to_bits, operations on sequences

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu