lua-users home
lua-l archive

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


On Fri, Dec 12, 2008 at 5:58 PM, Mike Pall <mikelu-0812@mike.de> wrote:
I've done the latter, since I needed it for LuaJIT 2.x anyway.
Here's an excerpt of the docs:
 http://lua-users.org/lists/lua-l/2008-09/msg00441.html

In fact, I've got a backport of the bit operations library for
standard Lua that has the same functionality and semantics.
I haven't released it yet, lacking the time to package, document
and support it. But if there's sufficient demand ...

Anyway, here are the specs:
- Supported functions: bit.tobit, bit.bnot, bit.band, bit.bor,
 bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror.
- Only 100 lines of C.
- Needs C99 <stdint.h>, but has MSVC workaround.
- Zero configuration in the standard case. One define is needed for
 the rare case of mixed-endian doubles.
- A simple Makefile for POSIX platforms. A BAT file for MSVC.
- Compiles out-of-the-box with GCC, MSVC and probably anything else.
- Works on 16, 32 and 64 bit platforms (with 2's-complement arithmetic,
 please :-) ).
- Works with lua_Number set to IEEE 754 doubles or to any signed
 integer type of 32 bits or more.
- Does not work with lua_Number = float (doesn't make much sense).
- Consistent semantics across all platforms. All operations work
 on 32 bits, independent of the size and type of lua_Number.
- Internal self-test on startup to detect miscompiles (wrong luaconf.h)
 and DirectX used with the wrong flags (bad FPU precision setting).
- Includes comprehensive tests and benchmarks.
- It's as fast as you can get with the standard Lua/C API.
- Author is reading the Lua mailing list. :-)

This sounds great.
 
Open issues:
- Lacks an appropriate project name that is not taken yet.

What about  lBit, Bit, or Bits?
--
Regards,
Ryan