Help with bit pattern
Per Gustafsson
per.gustafsson@REDACTED
Thu Aug 24 19:27:47 CEST 2006
It is not possible to use arithemetic expressions inside binary
patterns. You have to rewrite it like this:
<<NBits1:5,_:3,_/binary>> = X,
Pad = (NBits1 * 4) rem 8), %% or however Pad should be calculated
<<NBits1:5, Xmin:NBits/signed, Xmax:NBits/signed, Ymin:NBits/signed,
Ymax:NBits/signed, _:Pad, FrameRate:16/little,
FrameCount:16/little, _/binary>> = X.
This restriction might however disappear in the future.
Joel Reymont wrote:
> Actually, there's a bug in my padding calculation. And padding in bits
> is what I'm trying to calculate.
>
> On Aug 24, 2006, at 3:54 PM, Joel Reymont wrote:
>
>> Folks,
>>
>> What's the proper way to say this?
>>
>> <<NBits1:5, Xmin:NBits/signed, Xmax:NBits/signed, Ymin:NBits/ signed,
>> Ymax:NBits/signed, _:((NBits1 * 4) rem 8), FrameRate:16/ little,
>> FrameCount:16/little, _/binary>> = X.
>>
>> I'm getting ** 1: illegal bit size **
>
>
> --
> http://wagerlabs.com/
>
>
>
>
>
More information about the erlang-questions
mailing list