Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A bitarray class for Ruby, implemented as a C extension.
C Ruby
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
examples Added boolean network example
LICENSE Added gem support
README Using malloc/free instead of Ruby's versions.
Rakefile Added rdoc task to Rakefile
TODO Implemented union and intersection.
VERSION Version bump to 0.5.1


A bit array class for Ruby, implemented as a C extension. Includes methods for
setting and clearing individual bits, and all bits at once. Also has the
standard array access methods, [] and []=, and it mixes in Enumerable.

Example usage:

    require 'bitarray'
    bm =
    bm[5] = 1
    puts bm
    bm ="10010110")
    bm.toggle_bit 3
    bm.clear_bit 0

The test/ directory has a unit test file, and benchmarking utility.

The examples/ directory has bloom filter dictionary-lookup demonstration.

This library has been compiled and tested on:
    ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]  (Ubuntu from src)
    ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]       (Ubuntu apt-get)
    ruby 1.8.7 (2008-08-11 patchlevel 72) [alpha-netbsd]

If you have success using it on any other version/platform combinations, I'd
like to know. Or if you have problems, I'd like to know that too. Report bugs

BitArray is available as a gem. Install it with

sudo gem install ingramj-bitarray -s

Alternately, you can clone the repository and build things manually.

See the TODO file for current limitations and plans.

See the LICENSE file for copyright and license information.

Some inspiration was taken from Peter Cooper's BitField class, and various Open
Source bitarray implementations found online, but this implementation contains
only original code, except for some parts for test.rb, which were modified from
BitField's unit test file.


Something went wrong with that request. Please try again.