[erlang-questions] Bitstring question
Mike Oxford
moxford@REDACTED
Wed Feb 12 08:01:44 CET 2014
Thank you!
But ...
64> <<0:2*/bits*, D/bits>>.
** exception error: bad argument
65> <<0:2, D/bits>>.
<<"!">>
?? Why does explicitly qualifying the 0:2 with /bits cause it to fail?
On Tue, Feb 11, 2014 at 10:41 PM, Karolis Petrauskas <k.petrauskas@REDACTED
> wrote:
> 1> D = <<33:6>>.
> <<33:6>>
> 3> E = <<0:2, D/bits>>.
> <<"!">>
> 5> <<F>> = E.
> <<"!">>
> 6> F.
> 33
>
> Karolis
>
> On Wed, Feb 12, 2014 at 8:36 AM, Mike Oxford <moxford@REDACTED> wrote:
> > << 0:2, D >> should concat the two. Erlang knows what D is.
> > <<0:2/bits, D:6/bits>> should construct a single 8-bit value.
> > <<D/integer>> should (IMO) be valid because the value (33) is within the
> > range of /integer
> >
> > How would you convert it back out to 33?
> >
> >
> > On Tue, Feb 11, 2014 at 10:32 PM, Dmitry Kolesnikov <
> dmkolesnikov@REDACTED>
> > wrote:
> >>
> >> Hello,
> >>
> >> Please see comments inline.
> >>
> >> Best Regards,
> >> Dmitry >-|-|-(*>
> >>
> >>
> >> > On 12.2.2014, at 8.27, Mike Oxford <moxford@REDACTED> wrote:
> >> >
> >> > D = <<33:6>>
> >> > <<33:6>>
> >> D is length 6 bit
> >> >
> >> > I want to convert that 6 bit value (33) into a numeric value.
> >> >
> >> > Why does <<0:2, D>> not work?
> >> Type and size is not specified
> >> > Why does <<0:2/bits, D:6/bits>> not work?
> >> Expected size is 8 bits but your bit string is 6
> >> > Why does <<D/integer>> not work?
> >> Integer is 32bit
> >>
> >> >
> >> > Thanks in advance!
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > erlang-questions mailing list
> >> > erlang-questions@REDACTED
> >> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140211/8b14f2c3/attachment.htm>
More information about the erlang-questions
mailing list