[erlang-questions] sub-byte endianness in bit syntax

Bob Ippolito bob@REDACTED
Thu Aug 16 02:57:56 CEST 2007


It takes a few seconds to figure this out yourself:

1> <<A:2/little, B:2/big, _:4>> = <<2#10100000>>, {A, B}.
{2,2}

On 8/15/07, Tony Finch <dot@REDACTED> wrote:
> I can't find anything in the documentation that describes the order in
> which the bits of a byte are used up by a sequence of sub-byte segments in
> the bit syntax. For big-endian data, like the standard IP header example,
> it makes sense to fill in bytes most significant end first, whereas for
> little endian data you should fill them least significant end first. These
> conflict if you append big and little endian bit strings - which would be
> mad, but I can't spot anything that says this causes an error.
>
> Tony.
> --
> f.a.n.finch  <dot@REDACTED>  http://dotat.at/
> IRISH SEA: SOUTHERLY, BACKING NORTHEASTERLY FOR A TIME, 3 OR 4. SLIGHT OR
> MODERATE. SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list