lua-users home
lua-l archive

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


On Wed, Oct 13, 2010 at 1:12 AM, KHMan <keinhong@gmail.com> wrote:
> On 10/13/2010 10:34 AM, David Manura wrote:
>>  local bits = bit.band(buffer, bit.lshift(1, nbits)-1)
> ...Is there any actual technical problem with using this instead?
>    bit.rshift(0xFFFFFFFF, 32 - nbits)

That would be clearer.  Another possibility would be "local n = 32 -
nbits; local bits = rshift(lshift(buffer, n), n)" to chop the
left-most n < 32 bits out of a known 32-bit width.