[erlang-questions] Basic question about Erlang binaries
Sean Cribbs
seancribbs@REDACTED
Sat Sep 26 06:29:51 CEST 2009
If the position of this bit is constant, I would think so, e.g. for the
33rd bit:
<<_:32, Bit:1/integer, _Rest/binary>> = Binary.
I am not certain of the implementation details of binaries, but I
believe it's simple pointer arithmetic. If that's the case, then it
would be proportional to the offset into the binary that you wanted.
How are you doing the pattern matching?
Sean
Igor Ribeiro Sucupira wrote:
> Hello.
>
> Can I retrieve the value of a specific bit position of an arbitrary
> Erlang binary in guaranteed constant time?
>
> >From some tests I've made, it seems pattern matching to pick a
> specific bit near the middle of a binary takes linear time with
> respect to the size of the binary. Is that correct?
>
> Thanks.
> Igor.
>
>
More information about the erlang-questions
mailing list