Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@extra-integer/bit-set-if

1.1.7 • Public • Published

Conditionally set or clear bits of 32-bit integer, without branching (not method).

const bitSetIf = require('@extra-integer/bit-set-if');
// bitSetIf(integer, mask, [flag=1])
 
bitSetIf(8, 2, 1);
// 10 (0x8 set 0x2 => 0xA)
bitSetIf(15, 3, 0);
// 12 (0xF clear 0x3 => 0xC)
bitSetIf(0x1234, 0x430, 1);
// 5684 (0x1234 set 0x430 => 0x1634)

extra-integer

Install

npm i @extra-integer/bit-set-if

DownloadsWeekly Downloads

5

Version

1.1.7

License

MIT

Unpacked Size

2.63 kB

Total Files

4

Last publish

Collaborators

  • avatar