[erlang-questions] Bit syntax

Trevor Woollacott trevorw@REDACTED
Wed Mar 9 15:27:50 CET 2011


Hi

It doesn't match in your first one because you have that extra byte (16#00) 
in the binary. The second one matches because A holds an extra 8 bits

Regards,
Trevor

--------------------------------------------------
From: "Bob Cowdery" <bob@REDACTED>
Sent: Wednesday, March 09, 2011 4:21 PM
To: "erlang-questions" <erlang-questions@REDACTED>
Subject: [erlang-questions] Bit syntax

> 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.
>
> Thanks
> Bob
>
> 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
>
> <<239,254,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>                      0,0,0,...>>
> 2> <<A:32, B:48, C:408>> = <<16#effe02:24,16#00:48,16#00,(8*51):408>>.
> <<239,254,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>  0,0,0,...>>
> 3> A.
> 4026401280
> 4> B.
> 0
> 5> C.
> 408
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 


More information about the erlang-questions mailing list