[erlang-questions] Truncation packing Integer into binary: bug or feature?
Fri Aug 22 00:12:34 CEST 2008
If one packs a large Erlang integer into a binary, and the binary
representation of that integer is too large for the number of bytes
specified, Erlang silently truncates it (see code below).
Is this a bug or a feature? I know that in C, integers overflow silently. I
would have thought Erlang would raise a badarg error or something. Or would
it negatively impact performance to check for overflow? Is there a place in
the docs I did not find that addresses this? I have searched the Erlang
documentation, Google and the Erlang mailing list archives for clues and
found nothing so far.
2> B = <<N:64/integer>>.
3> <<N1:64/integer>> = B.
I'm using R12B-3 on x86_64 Ubuntu.
For every expert there is an equal and opposite expert - Arthur C. Clarke
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions