Transform Bitstring / Hex

Hi,

I have an 4 byte long hex string and want to convert them to an another format.
Shifting does not worked out for me, so I tried to grep every single byte and rebuild them to a new
hex string in the correct DCBA format.

AN possible solution was:

<<mA::8, mB::8>> = <<ID>>
    mid = <<mD, mC, mB, mA>>

I hope someone knows more than me about Bitwise in Elixir.

Thank your for your support!

1 Like

Hello,

sorry I don’t understand your question. Can you give me an example of what string you have and what you want as a result of this string?

3 Likes

Your binary pattern matching solution looks good to me. :+1:

I’d say binary patterns are preferred over shifting where possible in elixir.

Is it producing the expected outputs?

1 Like