Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
count-trailing-zeros
Advanced tools
Counts the number of trailing zeros for an integer in binary.
var ctz = require('count-trailing-zeros')
for(var i=1; i<=16; ++i) {
console.log(i+' (bin '+i.toString(2)+') has '+ctz(i)+' trailing zeros')
}
1 (bin 1) has 0 trailing zeros
2 (bin 10) has 1 trailing zeros
3 (bin 11) has 0 trailing zeros
4 (bin 100) has 2 trailing zeros
5 (bin 101) has 0 trailing zeros
6 (bin 110) has 1 trailing zeros
7 (bin 111) has 0 trailing zeros
8 (bin 1000) has 3 trailing zeros
9 (bin 1001) has 0 trailing zeros
10 (bin 1010) has 1 trailing zeros
11 (bin 1011) has 0 trailing zeros
12 (bin 1100) has 2 trailing zeros
13 (bin 1101) has 0 trailing zeros
14 (bin 1110) has 1 trailing zeros
15 (bin 1111) has 0 trailing zeros
16 (bin 10000) has 4 trailing zeros
npm i count-trailing-zeros
require('count-trailing-zeros')(v)
Count the number of trailing zeros.
v
is an integerReturns The number of trailing zeros of v
Note For a full balanced binary tree with 2^n elements arranged in order, this is the trailing zeros the index of an element is the same as its height in the tree.
(c) 2015 Mikola Lysenko. MIT License
FAQs
Counts the number of trailing zeros of a binary integer
The npm package count-trailing-zeros receives a total of 256 weekly downloads. As such, count-trailing-zeros popularity was classified as not popular.
We found that count-trailing-zeros demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.