Why not?<br><br>unpack(UD) -><br> << <<0:1,X/bits>> || <<X:7/bits>> <= UD >>.<br><br><div class="gmail_quote">2009/3/5 Tony Seebregts <span dir="ltr"><<a href="mailto:tony.seebregts@gmail.com">tony.seebregts@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This is an extract from the code I use:<div><br></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
<div>unpack(UD) -></div><div> septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])).</div><div><br></div><div>septets(T) -></div><div> [ flipx(X) || <<X:7>> <= T].</div><div><br></div>
<div>% Flips the bits in an octet/septet for easy unpacking</div><div><br></div><div>flip(Octet) -></div><div> <<B8:1,B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1>> = <<Octet>>,</div><div> <<B1:1,B2:1,B3:1,B4:1,B5:1,B6:1,B7:1,B8:1>>.</div>
</blockquote><div> </div><div>There is probably a better way of doing it but I was in a rush at the time :-)</div><div><br></div><div><br></div><div><br></div><div><br></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil<br>
<br>Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero!<br>Try Good Data now for free: <a href="http://www.gooddata.com">www.gooddata.com</a><br>