[erlang-questions] binary elements greater than 255

Igor Ribeiro Sucupira <>
Sat Apr 26 04:02:37 CEST 2008


I think this is the classic situation "If you do it wrong, the
behaviour is undefined".  :-)
(On the case at hand, it looks it's just taking the least significant
byte from the number)

In fact, maybe it should raise a warning when compiling a module with
this kind of code... (?)

On Fri, Apr 25, 2008 at 10:01 PM, Zvi <> wrote:
>
>  Hi Igor,
>
>  I know that lately computer industry decided to switch from 6-bit to 8-bit
>  bytes :), which when unsigned can hold values in range 0..255. But this
>  wasn't my question. I asked, why Erlang compiler didn't return error, when
>  you give it input like <<256>>. I think it's a bug.
>
>  Zvi
>
>
>  Igor Ribeiro Sucupira wrote:
>  >
>  > No.
>  > If you use integers in a binary, each must be in the range [0, 255]
>  > (1-byte).
>  >
>  > Igor.
>  >
>  > On Fri, Apr 25, 2008 at 7:44 PM, Zvi <> wrote:
>  >>
>  >>  Is this a bug?
>  >>  Zvi
>  >>  ------------------------------------------------------------
>  >>  Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0]
>  >>
>  >>  Eshell V5.6  (abort with ^G)
>  >>  1>
>  >>  1> <<0,255>>.
>  >>  <<0,255>>
>  >>  2> <<0,256>>.
>  >>  <<0,0>>
>  >>  3> <<0,257>>.
>  >>  <<0,1>>
>  >>  4> <<0,65536>>.
>  >>  <<0,0>>
>  >>  5> <<0,1111111111>>.
>  >>  <<0,199>>
>  >>  6>



More information about the erlang-questions mailing list