Skip to content
Subhajit Sahu edited this page Jun 6, 2020 · 14 revisions

Counts bits set. 🏃 📼 📦 🌔 📒

Similar: count, parity.

bit.count(x);
// x: an int32
const bit = require('extra-bit');

bit.count(7);
// 3 (111 => 3)

bit.count(12);
// 2 (1100 => 2)

bit.count(63);
// 6 (111111 => 6)

references

Clone this wiki locally