Concatenation of bit strings (not binaries) in Erlang

How do you combine bitstrons. I mean bistrons because I don't know how many bytes should be a multiple of 8.

A = <<3:2>>
B = <<1:1>>
C = <<15:4>>

Solution should A|B|C should be <<127:7>>

thank

+5
source share
1 answer

Create the binary using / bitstring and all the previous values. Here is an example running in the erlang shell:

1> A = <<3:2>>.
<<3:2>>
2> B = <<1:1>>.
<<1:1>>
3> C = <<15:4>>.
<<15:4>>
4> D = <<A/bitstring, B/bitstring, C/bitstring>>.
<<127:7>>
+12
source

All Articles