[erlang-questions] Bit syntax

Vlad Dumitrescu <>
Wed Mar 9 15:29:41 CET 2011


Hi!

On Wed, Mar 9, 2011 at 15:21, Bob Cowdery <> wrote:

> Hi
>
> I'm clearly not understanding the bit syntax properly. Could someone
> explain to me what I am doing wrong here. Why does the first not match
> when its the right shape but the second does when its the wrong shape.
> The bound values don't make much sense to me either.
>
> 1> <<A:24, B:48, C:408>> = <<16#effe02:24,16#00:48,16#00,(8*51):408>>.
> ** exception error: no match of right hand side value
>

There is an "extra" 16#00 on the right side that is not matched on the left.



> 2> <<A:32, B:48, C:408>> = <<16#effe02:24,16#00:48,16#00,(8*51):408>>.
>

The larger size for A "swallows" the extra value, but shifts the values a
byte to the right.

regards,
Vlad


More information about the erlang-questions mailing list