Skip to content

toggleAs

Subhajit Sahu edited this page Jan 17, 2021 · 7 revisions

Toggles bits as per mask. 🏃 📼 📦 🌔 📒

Alternatives: toggle, toggleAs.
Similar: get, set, toggle.

bit.toggleAs(x, m);
// x: an int32
// m: bit mask
const bit = require('extra-bit');

bit.toggleAs(6, 1);
// 7 (110,000 => 111)

bit.toggleAs(6, 7);
// 1 (110,111 => 001)

bit.toggleAs(6, 3);
// 5 (110,011 => 101)

references

Clone this wiki locally