lua-users home
lua-l archive

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

On 10/13/2010 10:34 AM, David Manura wrote:
  local bits =, bit.lshift(1, nbits)-1)

Don't like how this line works at all.

> print(bit.lshift(1,32))

So it gets % 2^32, then bit.lshift(1,32)-1 = 0-1 = -1 ... ewww

Is there any actual technical problem with using this instead?

    bit.rshift(0xFFFFFFFF, 32 - nbits)

Assuming we are fixed at 32 bits max, it means that we shift out unwanted mask bits -- nothing unclear about it. I think "bit.lshift(1, nbits)-1" is simply something one does in C. Doesn't mean we must paint in Lua in the same way.

I think compression/decompression routines written in Lua is more suitable for prototyping work and hence performance is not a critical issue -- it's not for any real "normal user" apps, is it?

Heavens, before long, someone will lobby for tweaks to run FFT or DCT in Lua...

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia