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

Gets n-bit parity. 🏃 📼 📦 🌔 📒

Similar: [count], parity.

bit.parity(x, [n]);
// x: an int32
// n: number of bits (1)
const bit = require('extra-bit');

bit.parity(7);
// 1 (1,1,1 => 1)

bit.parity(5);
// 0 (1,0,1 => 0)

bit.parity(8, 2);
// 2 (10,00 => 10)

bit.parity(63, 4);
// 12 (11,1111 => 1100)

references

Clone this wiki locally