https://github.com/pot-pourri/bit
:two: Bit twiddling hacks for JavaScript
https://github.com/pot-pourri/bit
agpl bit-algorithms bit-manipulation bit-tricks bit-twiddling-hacks javascript
Last synced: 7 months ago
JSON representation
:two: Bit twiddling hacks for JavaScript
- Host: GitHub
- URL: https://github.com/pot-pourri/bit
- Owner: pot-pourri
- License: agpl-3.0
- Created: 2014-09-06T12:59:48.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-04-26T14:08:46.000Z (over 4 years ago)
- Last Synced: 2025-04-08T11:03:19.032Z (7 months ago)
- Topics: agpl, bit-algorithms, bit-manipulation, bit-tricks, bit-twiddling-hacks, javascript
- Language: JavaScript
- Homepage: https://aureooms.github.io/js-bit
- Size: 113 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 59
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[js-bit](http://make-github-pseudonymous-again.github.io/js-bit)
==
Bit twiddling hacks code bricks for JavaScript.
[](https://raw.githubusercontent.com/make-github-pseudonymous-again/js-bit/master/LICENSE)
[](https://www.npmjs.org/package/@aureooms/js-bit)
[](http://bower.io/search/?q=@aureooms/js-bit)
[](https://travis-ci.org/make-github-pseudonymous-again/js-bit)
[](https://coveralls.io/r/make-github-pseudonymous-again/js-bit)
[](https://david-dm.org/make-github-pseudonymous-again/js-bit#info=dependencies)
[](https://david-dm.org/make-github-pseudonymous-again/js-bit#info=devDependencies)
[](https://codeclimate.com/github/make-github-pseudonymous-again/js-bit)
[](https://www.npmjs.org/package/@aureooms/js-bit)
[](https://github.com/make-github-pseudonymous-again/js-bit/issues)
[](http://inch-ci.org/github/make-github-pseudonymous-again/js-bit)
Can be managed through [duo](https://github.com/duojs/duo),
[component](https://github.com/componentjs/component),
[bower](https://github.com/bower/bower), or
[npm](https://github.com/npm/npm).
```js
let bit = require( "@aureooms/js-bit" ) ;
```
Example usage:
```js
/* Compute the sign of an integer */
bit.sign( 0 ) ; // 0
bit.sign( -67 ) ; // -1
bit.sign( 432 ) ; // +1
/* Compute the lexicographically next bit permutation */
bit.next( 0b00101001 ) ; // 0b00101010
```
References:
- https://graphics.stanford.edu/~seander/bithacks.html
- https://github.com/boothj5/bit-twiddling/blob/master/basic.c