                          bitlib release 24
                          -----------------

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


bitlib is a C library for Lua 5.x that provides bitwise operations. It
is copyright Reuben Thomas 2000-2007, 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 John Stiles for a bug
fix.


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

As normal:

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

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
  --with-lua-suffix=ARG   Lua binary and library files are suffixed with ARG

For example, on Debian:

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


Use
---

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

Lua functions provided:

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. By default, the numbers
used are 32-bit. This can be changed by redefining Integer and
UInteger at the top of lbitlib.c. The type used should at most have
the same number of bits as the mantissa of lua_Number, to avoid
casting problems. lua_Number is typically a 64-byte IEEE float, which
has a 53 bit mantissa.

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.
