[erlang-questions] binary syntax bug?

Edwin Fine <>
Thu Oct 16 16:06:19 CEST 2008


According to my understanding of the documentation (Programming Examples),
this is correct behavior.

1. Default integer size is 8 bits if unspecified.
2. If more data than the size specified is provided, it will be truncated to
the least significant bits. So 01020304 becomes 04 (8 bits).

I had originally reported this as a bug, but was told it is a feature. There
is an EEP to provide a compile-tme option to throw an exception if the
truncation is going to happen.

Sorry you were bitten by this one, too.

On Thu, Oct 16, 2008 at 7:47 AM, Serge Aleynikov <> wrote:

> Expected:
>
> 1> <<(16#01020304):32/integer>>.
> <<1,2,3,4>>
> 2> <<16909060/integer>>.
> * 3: syntax error before: '<<'
>
> Unexpected:
>
> 1> <<16#01020304/integer>>.
> <<4>>
> 2> <<(16#01020304)/integer>>.
> <<4>>
>
> Serge
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081016/4d74a39b/attachment.html>


More information about the erlang-questions mailing list