[erlang-questions] bit syntax: 0-sized segments
Max Lapshin
max.lapshin@REDACTED
Fri Mar 8 09:30:10 CET 2013
0:Pad
Pad can be zero-length.
On Fri, Mar 8, 2013 at 12:32 PM, Kostis Sagonas <kostis@REDACTED> wrote:
> On 03/08/2013 08:58 AM, Ulf Wiger wrote:
>
>>
>> On 8 Mar 2013, at 08:38, Dan Gudmundsson wrote:
>>
>> Another nice thing with 0 sized integers is when you add alignment
>>> bits in protocols, in both
>>> matching and creation.
>>>
>>
>> I make use of this in sext as well, in a number of places:
>>
>> encode_bin_elems(<<>>) ->
>> <<8>>;
>> encode_bin_elems(B) ->
>> Pad = 8 - (size(B) rem 8),
>> << (<< <<1:1, B1:8>> ||<<B1>> <= B>>)/bitstring, 0:Pad, 8>>.
>>
>
> I fail to see where this creates a 0-sized integer...
>
> Kostis
>
> ______________________________**_________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130308/64af6708/attachment.htm>
More information about the erlang-questions
mailing list