Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Tiny library for bitwise operations

tree: fd0b9244f8

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 cmake Updated lua macros December 19, 2012
Octocat-spinner-32 m4 Import to git October 01, 2010
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 AUTHORS Import to git October 01, 2010
Octocat-spinner-32 CMakeLists.txt Formated CMakeLists.txt July 26, 2012
Octocat-spinner-32 COPYING Import to git October 01, 2010
Octocat-spinner-32 ChangeLog Import to git October 01, 2010
Octocat-spinner-32 INSTALL Import to git October 01, 2010
Octocat-spinner-32 Makefile.am Import to git October 01, 2010
Octocat-spinner-32 Makefile.in Import to git October 01, 2010
Octocat-spinner-32 NEWS Import to git October 01, 2010
Octocat-spinner-32 README Import to git October 01, 2010
Octocat-spinner-32 aclocal.m4 Import to git October 01, 2010
Octocat-spinner-32 bit.def Import to git October 01, 2010
Octocat-spinner-32 bit_limits.h Import to git October 01, 2010
Octocat-spinner-32 config.guess Import to git October 01, 2010
Octocat-spinner-32 config.sub Import to git October 01, 2010
Octocat-spinner-32 configure Import to git October 01, 2010
Octocat-spinner-32 configure.ac Import to git October 01, 2010
Octocat-spinner-32 depcomp Import to git October 01, 2010
Octocat-spinner-32 dist.info Import to git October 01, 2010
Octocat-spinner-32 find_limits.lua Import to git October 01, 2010
Octocat-spinner-32 install-sh Import to git October 01, 2010
Octocat-spinner-32 lbitlib.c Import to git October 01, 2010
Octocat-spinner-32 ltmain.sh Import to git October 01, 2010
Octocat-spinner-32 missing Import to git October 01, 2010
Octocat-spinner-32 test.lua Import to git October 01, 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.
Something went wrong with that request. Please try again.