http://bitop.luajit.org/index.html
Lua BitOp is a C extension module for Lua 5.1/5.2which adds bitwise operations on numbers.
Lua BitOp is Copyright © 2008-2012 Mike Pall.Lua BitOp is free software, released under theMIT license(same license as the Lua core).
Features
- Supported functions:bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor,bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
- Consistent semanticsacross 16, 32 and 64 bit platforms.
- Supports different lua_Number types:either IEEE 754 doubles, int32_t or int64_t.
- Runs on Linux, *BSD, Mac OS X, Windows and probably anything elseyou can find.
- Simple installation on all systems.No bulky configure scripts. Embedded-systems-friendly.
- Internal self-test on startup to detect miscompiles.Includes a comprehensive test and benchmark suite.
- Compatible with the built-in bitwise operations inLuaJIT 2.0.
- It's as fast as you can get with the standard Lua/C API.
More ...
Please click on one of the links in the navigation bar to your leftto learn more.
Please visit the Download page to fetchthe current version of Lua BitOp.
News
-
2012-05-08
Lua BitOp 1.0.2 has been released
-
This release adds compatibility with both Lua 5.1 and Lua 5.2.
Embedding Lua BitOp
If you're embedding Lua into your application, it's quite simple toadd Lua BitOp as a static module:
1. Copy the file bit.c from the Lua BitOp distributionto your Lua source code directory.
2. Add this file to your build script (e.g. modify the Makefile) orimport it as a build dependency in your IDE.
3. Edit lualib.h and add the following two lines:
#define LUA_BITLIBNAME "bit" LUALIB_API int luaopen_bit(lua_State *L);
4. Edit linit.c and add this immediately before the linewith {NULL, NULL}:
{LUA_BITLIBNAME, luaopen_bit},
5. Now recompile and you're done!