extra-bit.min
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

The bit is a basic unit of information in information theory, computing. This package includes bit twiddling hacks by Sean Eron Anderson and many others.
📦 NPM, 😺 GitHub, 🏃 RunKit, 📼 Asciinema, 🌔 Minified, 📜 Files, 📰 JSDoc, 📘 Wiki.

Stability: Experimental.

This is browserified, minified version of extra-bit.
It is exported as global variable bit.
CDN: unpkg, jsDelivr.


const bit = require("extra-bit");
// import * as bit from "extra-bit";
// import * as bit from "https://unpkg.com/extra-bit@1.0.50/index.mjs"; (deno)

bit.count(7);
// 3 (111 ⇒ 3)

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

bit.swap(6, 1, 0);
// 5 (110 ⇒ 101)

bit.reverse(0xFFFF0000);
// 65535 (0x0000FFFF)

bit.signExtend(15, 4);
// -1


Index

Method Action
get Gets a bit.
set Sets a bit.
toggle Toggles a bit.
swap Swaps bit sequences.
scan Finds index of first set bit from LSB.
count Counts bits set.
parity Finds n-bit parity.
rotate Rotates bits.
reverse Reverses all bits.
merge Merges bits as per mask.
interleave Interleaves bits of two int16s.
signExtend Sign extends variable bit-width integer.


Package Sidebar

Install

npm i extra-bit.min

Weekly Downloads

51

Version

2.0.1

License

MIT

Unpacked Size

16.4 kB

Total Files

7

Last publish

Collaborators

  • wolfram77