[erlang-bugs] Documentation request: integer encoding and truncation
Fri Aug 22 19:09:30 CEST 2008
I refer to the following post. I was caught unawares by this apparently
May I strongly recommend placing this information (taken from the above
post) in the Erlang Reference Manual, in the section on binaries. It may
save other people time and confusion. A further question is whether or not
this *should* be the behavior. As a language used for writing highly
reliable systems, shouldn't this overflow condition be caught? Maybe as an
optional run-time flag?
Integer Encoding and Truncation
is equivalent to
<<(I band ((1 bsl N) - 1)):N>>
That is, if the integer I can not be represented in N bits, the low N bits
of the integer is put into the binary.
Binaries work in a similar manner e.g.
1> <<1,2>> = << (<<1,2,3>>):2/binary >>.
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-bugs