lua-users home
lua-l archive

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


On Mon, Dec 1, 2014 at 1:07 PM, Thiago L. <fakedme@gmail.com> wrote:
> -- bit flags for stuff
> 0b0_1_0_100_101_001_1010_1


yes, that's quite useful too, especially when driving hardware from
Lua, as we all do all the time. :-)

sometimes i've done things like this:

function b(s)
    local o = 0
    for d in s:gmatch('[01]') do
        o = o * 2 + tonumber(d)
    end
    return o
end

b'1010_0010'
=>162


-- 
Javier