@aureooms/js-bit
v1.0.6
Published
bit twiddling hacks code bricks for JavaScript
Downloads
10
Maintainers
Readme
js-bit
Bit twiddling hacks code bricks for JavaScript.
Can be managed through duo, component, bower, or npm.
let bit = require( "@aureooms/js-bit" ) ;
Example usage:
/* 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