lua-users home
lua-l archive

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


Mike Pall wrote:
> Tim Channon wrote:
>> Mike Pall wrote:
>>> Anyway, here are the specs:
>>> - Supported functions: bit.tobit, bit.bnot, bit.band, bit.bor,
>>>   bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror.
>>> - Only 100 lines of C.
>> Licence?
> 
> Same as Lua (MIT/X).
> 
> --Mike
> 
 Good.

I know it is creep-ism, not something I like.

But.

It would be good to include a few best-done-at-machine-level set operations.

include(set, x)
exclude(set, x)
in(set, x)
count(set)  (number of bits at 1)

Can donate the following as a starting point for Lua licence code, below
is from a prog where I needed that data size. Various PD bit count code
exists, an awkward functionality in high level.

static unsigned short *incl(unsigned short *set, unsigned bit){  *set |=
(1 << bit); return set;}

static unsigned short *excl(unsigned short *set, unsigned bit){  *set =
((*set)&(~(1 << bit))); return set;}

static unsigned short in(unsigned short set, unsigned bit){ return
(set&(1 << bit))!=0;}

Tim