[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Binary notation for integers: 0b[10]+
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 1 Dec 2014 16:52:29 -0200
> function b(s)
> local o = 0
> for d in s:gmatch('[01]') do
> o = o * 2 + tonumber(d)
> end
> return o
> end
Or just this:
function b(s)
return tonumber(s:gsub("[^%d]",""),2)
end