[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Binary notation for integers: 0b[10]+
- From: Javier Guerra Giraldez <javier@...>
- Date: Mon, 1 Dec 2014 13:47:31 -0500
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