<div dir="ltr">I refer to the following post. I was caught unawares by this apparently undocumented behavior.<br><br><a href="http://www.erlang.org/pipermail/erlang-questions/2007-July/027657.html">http://www.erlang.org/pipermail/erlang-questions/2007-July/027657.html</a><br>
<br>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 <b>should</b> 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?<br>
<br><font size="4">Integer Encoding and Truncation<br></font><br><span style="font-family: courier new,monospace;"><<I:N>></span><br><br>is equivalent to<br><br><span style="font-family: courier new,monospace;"><<(I band ((1 bsl N) - 1)):N>></span><br>
<br>That is, if the integer <span style="font-family: courier new,monospace;">I</span> can not be represented in <span style="font-family: courier new,monospace;">N</span> bits, the low <span style="font-family: courier new,monospace;">N</span> bits of the integer is put into the binary.<br>
<br>Binaries work in a similar manner e.g.<br><br><span style="font-family: courier new,monospace;">1> <<1,2>> = << (<<1,2,3>>):2/binary >>.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><<1,2>></span><br clear="all"><br>Regards,<br>Edwin Fine<br>-- <br>For every expert there is an equal and opposite expert - Arthur C. Clarke<br>
</div>