How to write a list of integers to a file as 16 bit values in Elixir -


i have list of integers values between [0-65535]. need write these file 16 bit integers.

how do in elixir?

i have searched, confused ints , binaries , how perform conversion 16 bit values.

i have found how convert 16 bit binary:

<<12345 :: size(16)>> 

you can alternatively use streams:

[1, 2, 3] |> stream.map(&<<&1::16>>) |> enum.into(file.stream!(filename)) 

this uses short form ::16 instead of ::size(16). file stream take care of opening , closing file automatically.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -