[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work1) now available
- From: Jay Carlson <nop@...>
- Date: Wed, 10 Jul 2013 16:10:58 -0400
On Wed, Jul 10, 2013 at 3:50 PM, Doug Currie <doug.currie@gmail.com> wrote:
> Well, as a programmer weaned on embedded control in tiny hardware,
All the 6502 weenies on the list are trying to decide how tiny is
tiny. :-) OK, a 68HC11 is pretty luxurious...
> a number is just one way to interpret a bit pattern. There are a lot of interesting things that can be done with these bit patterns that blur the distinction between numbers and "non-numbers," whatever those are.
>
> Examples (in C) of things I've found useful in my work:
>
> - isolate the rightmost set bit: x & (-x)
>
> - sign extend a field: ((x ^ N) - N) -- where N is the numeric representation of the sign bit, e.g., 32768 for 16 bits
>
> - integer log base 2: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
Let me second http://graphics.stanford.edu/~seander/bithacks.html to
those who have not seen it.
On the other hand many of those tricks are especially useful in tight
loops and vectorized/pipelined. In PUC-Rio liblua, interpreter
overhead can swamp the actual bitops, (consider all the unpredicted
branches etc). A call to a C function like bit32.extract can be cheap
if it performs multiple steps. Even if some of those steps are
unnecessary, they're cheaper than dispatching more bytecode.
LuaJIT is different, but the spirit of LuaJIT is to give you both
diamond and obsidian knives to cut (yourself) with.
Jay
- References:
- Re: [ANN] Lua 5.3.0 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.3.0 (work1) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.3.0 (work1) now available, Enrico Colombini
- Re: [ANN] Lua 5.3.0 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work1) now available, Lorenzo Donati
- Re: [ANN] Lua 5.3.0 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work1) now available, Lorenzo Donati
- Re: [ANN] Lua 5.3.0 (work1) now available, Joseph Manning
- Re: [ANN] Lua 5.3.0 (work1) now available, Todd Coram
- Re: [ANN] Lua 5.3.0 (work1) now available, Lorenzo Donati
- Re: [ANN] Lua 5.3.0 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work1) now available, Jerome Vuarand
- Re: [ANN] Lua 5.3.0 (work1) now available, Ico
- Re: [ANN] Lua 5.3.0 (work1) now available, Lorenzo Donati
- Re: [ANN] Lua 5.3.0 (work1) now available, Philipp Janda
- Re: [ANN] Lua 5.3.0 (work1) now available, Doug Currie
- Re: [ANN] Lua 5.3.0 (work1) now available, Philipp Janda
- Re: [ANN] Lua 5.3.0 (work1) now available, Doug Currie