Binary to integer

Matthias Lang <>
Sat Dec 7 10:10:39 CET 2002


Eduardo Figoli writes:

 > Does someone know how to convert a binary 4 bytes expression to integer ?

7> <<I:32>> = <<1,2,3,4>>.
<<1,2,3,4>>
8> I.
16909060

The "bit syntax" I used above has many options for word widths and
endianness. It's described in "Languages Extensions since 4.4":

  http://www.erlang.org/doc/r9b/doc/extensions/bit_syntax.html#6

I also recommend the entire "Language Extensions" part of the manual:

  http://www.erlang.org/doc/r9b/doc/extensions/part_frame.html

Matthias



More information about the erlang-questions mailing list