lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Many binary protocols are more easily expressible with raw binary than
hex. This is because, to save space, single bits are often used to
represent something (possibly a continuation bit), thus allowing a
tighter packing.

This is used, for example, in websocket code to indicate continuation
frames or signal the existence of an extension. It's also useful when
implementing protocol buffers (variable width integers in particular).
Unicode is, of course, the canonical example.

On Sat, Mar 22, 2014 at 10:58 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Sun, Mar 23, 2014 at 12:38 AM, Lorenzo Donati
> <lorenzodonatibz@tiscali.it> wrote:
>> 1. Binary literals, such as 0b100101101, or something like that.
>
> Easy enough to write:
>
>> function B(b) return tonumber(b,2) end
>> B'1010'
> 10
>
> But it's true these are not literals and involve a function call.  I
> don't know of the general usefullness; mostly binary is used for
> training and then people move over to the more compact hex.
>
>> 2. A not significant digit separator for better readability of long numbers:
>
> It would be nice - I find myself counting zeros....
>