[erlang-questions] Bit Packing question

Bob Ippolito bob@REDACTED
Sat Dec 13 04:39:47 CET 2014


'bytes' is for packing binaries, not numbers. The working example you have
is the correct way to do it.

On Friday, December 12, 2014, Santosh Kumar <santosh79@REDACTED> wrote:

> Hi group,
> I was trying to pack a number into 4 bytes and was having a hard time
> doing it. Here is what I was trying:
>
> 102> Num = 128.
>
> 128
>
> 103> <<Num:4/bytes>>.
>
> ** exception error: bad argument
>
>
> While this works:
>
>
> 104> <<Num:32>>.
>
> <<0,0,0,128>>
>
>
> Here the packing into 32 bits works but the packing into 4 bytes fails.
> Not sure why.
>
>
> Any help, much appreciated.
>
>
> Thanks
>
> Santosh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141212/596cfada/attachment.htm>


More information about the erlang-questions mailing list