Tiny library for bitwise operations
Shell Other
Clone or download
Latest commit 75a62d1 Feb 18, 2013
Permalink
Failed to load latest commit information.
cmake Updated lua macros Dec 19, 2012
m4 Import to git Oct 1, 2010
.travis.yml Updated travis hook Feb 18, 2013
AUTHORS Import to git Oct 1, 2010
CMakeLists.txt Formated CMakeLists.txt Jul 26, 2012
COPYING Import to git Oct 1, 2010
ChangeLog Import to git Oct 1, 2010
INSTALL Import to git Oct 1, 2010
Makefile.am Import to git Oct 1, 2010
Makefile.in Import to git Oct 1, 2010
NEWS Import to git Oct 1, 2010
README Import to git Oct 1, 2010
aclocal.m4 Import to git Oct 1, 2010
bit.def Import to git Oct 1, 2010
bit_limits.h Import to git Oct 1, 2010
config.guess Import to git Oct 1, 2010
config.sub Import to git Oct 1, 2010
configure Import to git Oct 1, 2010
configure.ac Import to git Oct 1, 2010
depcomp Import to git Oct 1, 2010
dist.info Import to git Oct 1, 2010
find_limits.lua Import to git Oct 1, 2010
install-sh Import to git Oct 1, 2010
lbitlib.c Import to git Oct 1, 2010
ltmain.sh Import to git Oct 1, 2010
missing Import to git Oct 1, 2010
test.lua Import to git Oct 1, 2010

README

                                bitlib
                                ------

                   by Reuben Thomas <rrt@sc3d.org>
                 http://luaforge.net/projects/bitlib


bitlib is a C library for Lua 5.1 that provides bitwise operations. It
is copyright Reuben Thomas 2000-2009, and is released under the MIT
license, like Lua (see http://www.lua.org/copyright.html; it's
basically the same as the BSD license). There is no warranty.

Please report bugs and make suggestions to the email address above, or
use the LuaForge trackers.

Thanks to John Passaniti for his bitwise operations library, some of
whose ideas I used, to Shmuel Zeigerman for the test suite, to
Thatcher Ulrich for portability fixes, and to Enrico Tassi, John
Stiles and Eduardo Ochs for bug reports.


Installation
------------

As normal:

    ./configure && make [&& make check] [&& make install]

If you get warnings about integer constants being too large, don't
worry. They won't be used.

The following options may be of interest if you have Lua installed on
non-default paths (as you are likely to on any system supporting more
than one version of Lua):

  --libdir=DIR            Install shared library in this directory
  --with-lua-prefix=DIR   Lua files are in DIR
  --with-lua-includes=DIR Lua include files are in DIR
  --with-lua-libraries=DIR
                          Lua library files are in DIR, or "no" if not used
  --with-lua-suffix=ARG   Lua binary and library files are suffixed with ARG

For example, on Debian or Ubuntu:

  ./configure --libdir=/usr/local/lib/lua/5.1 --with-lua-includes=/usr/include/lua5.1 --with-lua-suffix=5.1 --with-lua-libraries=no


Use
---

Make sure the library is installed on your LUA_CPATH, and require it.

The library provides the constant bit.bits that gives the number of
bits that can be used in bitwise operations, and the following
functions:

bit.cast(a)        cast a to the internally-used integer type
bit.bnot(a)        returns the one's complement of a
bit.band(w1, ...)  returns the bitwise and of the w's
bit.bor(w1, ...)   returns the bitwise or of the w's
bit.bxor(w1, ...)  returns the bitwise exclusive or of the w's
bit.lshift(a, b)   returns a shifted left b places
bit.rshift(a, b)   returns a shifted logically right b places
bit.arshift(a, b)  returns a shifted arithmetically right b places

All function arguments should be integers that fit into the C type
lua_Integer.

The logical operations start with "b" for "bit" to avoid clashing with
reserved words; although "xor" isn't a reserved word, it seemed better
to use "bxor" for consistency.