[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bitflags
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Tue, 4 Mar 2003 11:54:49 +0100
Hi,
> so what are people doing in the
> interim to address this?
To test a single flag bit I once used the following (Lua 4 code, mod moved
to math.mod in Lua 5):
function testflag(x, n) -- n should be a power of 2
return mod(x, 2*n) >= n
end
Making mod an upvalue speeds things up slightly:
do
local mod = mod
function testflag(x, n) -- n should be a power of 2
return %mod(x, 2*n) >= n
end
end
Bye,
Wim