lua-users home
lua-l archive

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

One thing I never understood about the various bit libraries (and a bit of an annoyance personally, no pun intended :) is the inconsistency and redundancy of the function names.

For example, the bitwise not, and, or, and xor functions are prefixed with b (I assume to denote that they are bit operations) but this is unnecessary as they are in the bit library (namespace, table, whatever) and will not collide with any other such named functions. (this is the redundancy nit I have)

In addition, the other functions are *not* prefixed with b, and yet they are also bit functions. (this is the inconsistency nit I have)

Is there any explanation for this?  Is it just some piece of history that everyone is following, or...?

This post is not meant to inflame, its just something I have been wondering for quite some time now.


On Tue, Jan 6, 2009 at 6:09 PM, Mike Pall <> wrote:
Lua BitOp is a C extension module for Lua 5.1 which adds
bitwise operations on numbers.

Lua BitOp is free software, released under the same license as Lua.

Change list for version 1.0.1:
- New bit.tohex function for portable conversion of results to
 hexadecimal strings. This was added because string.format("%x", x)
 fails for negative numbers on some platforms.
- Added missing LUA_LIB define.
- Self-tests checks for arithmetic right-shift semantics.

Here is a link to the project home page with full docs:

And a direct link to the download page:

- Supported functions: bit.tobit, bit.tohex, bit.bnot,, bit.bor,
 bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
- Consistent semantics across 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 else
 you can find.
- Simple installation on all systems. No bulky configure scripts.
- Internal self-test on startup to detect miscompiles.
 Includes a comprehensive test and benchmark suite.
- Compatible with the bitwise operations in the upcoming LuaJIT 2.x.
- It's as fast as you can get with the standard Lua/C API.