/bit-twiddling-hacks

Implementation of Sean Anderson's Bit Twiddling Hacks

Primary LanguageCGNU General Public License v3.0GPL-3.0

BitOperations

License GPLv3 AppVeyor build status Travis build status Coveralls coverage

Several bit operations and manipulations, also known as 'bit hacks'.

Please note that the coverage results do not include the function macros, although those are tested in the unit tests.

Documentation

Documentation can be found in the documentation page, and for the function macros and functions on the BitOperations.h documentation page.
For the functions that are based on Sean Eron Anderson's Bit Twiddling Hacks the arithmetics are explained on Joe Gibson's markdown version of Sean Eron Anderson's Bit Twiddling Hacks.

Usage

In order to use this code the only thing that you need to do is copy BitOperations.h and BitOperations.c to your project and include BitOperations.h in the files where you intend to use the BitOperations. These two files can be found in every release in the source and source/src folders respectively.

Unit test

The unit tests use greatest by Scott Vokes. Greatest is licensed under a custom license.
The purpose of this unit test is not to verify that the arithmetic is correct, because Sean Eron Anderson already tested that thoroughly. This unit test verifies that the implementation is correct.

All the functions and function macros are tested by the unit tests, of which the log can be found in every travis build or in every AppVeyor build.

Licensing

GNU General Public License version 3 or later, as published by the Free Software Foundation. Modification and redistribution are permitted according to the terms of the GPL. The license can be found in the LICENSE file.

Pull requests and bug reports/suggestions are welcome!