# [erlang-questions] Bitstring question

Karolis Petrauskas <>
Wed Feb 12 07:41:29 CET 2014

```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 <> 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 <>
> wrote:
>>
>> Hello,
>>
>>
>> Best Regards,
>> Dmitry >-|-|-(*>
>>
>>
>> > On 12.2.2014, at 8.27, Mike Oxford <> 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
>> >
>> > http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
>
> http://erlang.org/mailman/listinfo/erlang-questions
>

```