[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Bit twiddling hacks (Lua 5.3 bitops/shifts)
- From: behoffski <behoffski@...>
- Date: Fri, 28 Mar 2014 16:52:06 +1030
(I read the list via digest, so apologies if someone else has
already noted this.)
There's quite a large number of bit-twiddling hacks that have been
collected together at:
http://graphics.stanford.edu/~seander/bithacks.html
Regarding copyright, the web page notes that "the code snippets
here are in the public domain." There may be patent problems with
some of the snippets, as noted in the discussion accompanying some
of the items.
All the hacks are presented as C code, with // comments. There
are right-shift operations used in a number of the hacks, and
sometimes the distinction between arithmetic right shift and logical
right shift is important.
Not sure how these hacks relate to the Lua 5.3 bit-operations
and/or 64-bit integer discussions; I can see pros and cons on both
sides.
At another level, the VM and/or JIT translation may find some value
in some of these hacks, although portability is an issue, and I
suspect that profitable hacks have already been incorporated where
appropriate.
cheers,
behoffski (Brenton Hoff)
Programmer, Grouse Software