[erlang-questions] surprising bit syntax

Dmitrii 'Mamut' Dimandt dmitriid@REDACTED
Tue Jul 3 13:40:18 CEST 2007


Ulf Wiger (TN/EAB) wrote:
>
> Is it just me, or is this behaviour surprising?
>
> 4> <<255>>.
> <<"ÿ">>
> 5> <<256>>.
> <<0>>
> 6> <<257>>.
> <<1>>
> 7> <<257:8>>.
> <<1>>
> 8> <<I:8/integer>> = <<999>>.         
> <<"ç">>
> 9> I.
> 231
>
> I scanned the reference manual to find a note stating that this
> is exactly what one should expect, but I couldn't find it.
>
> Personally, I would have expected something along the lines
> of badarg, which is what list_to_binary([999]) gives.
>
My results are consistent with yours:

1> <<255>>.
<<"\377">>
2> <<256>>.
<<0>>
3> <<257>>.
<<1>>
4> <<257:8>>.
<<1>>
5> <<I:8/integer>> = <<999>>.
<<"\347">>
6> I.
231



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070703/06e383f4/attachment.htm>


More information about the erlang-questions mailing list