https://github.com/denq/count-bits
Helper for counting bits in numbers
https://github.com/denq/count-bits
algorithm algorithms binary bits count-bits counter number
Last synced: 9 months ago
JSON representation
Helper for counting bits in numbers
- Host: GitHub
- URL: https://github.com/denq/count-bits
- Owner: DenQ
- License: mit
- Created: 2017-04-22T08:29:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-22T09:52:04.000Z (over 8 years ago)
- Last Synced: 2025-02-19T21:37:46.140Z (10 months ago)
- Topics: algorithm, algorithms, binary, bits, count-bits, counter, number
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# count-bits
It is helper for counting bits in numbers
## Install
npm install count-bits --save
## Usage
var countBits = require('count-bits');
countBits(15) === 4; // true, 15 === 1111
countBits(16) === 1; // true, 15 === 1000
## Specialty
This package works much faster than analogs.
Because it does not look for a substring in a string and does not use regular expressions.
## Testing
npm test