Skip to content
wolfram77 edited this page Apr 13, 2020 · 14 revisions

Counts bits set.

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