[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bit.lshift and performance - luabitop v.s. lua-5.2.0-work4
- From: David Manura <dm.lua@...>
- Date: Wed, 13 Oct 2010 02:17:55 -0400
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.