2.2.48 ā€¢ Published 6 months ago

extra-bit.web v2.2.48

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

The bit is a basic unit of information in information theory, computing. šŸ“¦ Node.js, šŸŒ Web, šŸ“œ Files, šŸ“° Docs, šŸ“˜ Wiki.

The concept of a bit, which stands for binary digit, has been a fundamental unit of information in the fields of information theory and computing. Bitwise operations are used to manipulate and process data at the bit level, and these operations are crucial for efficient programming in a variety of domains, such as computer graphics and cryptography. JavaScript converts a Number (a 64-bit floating point number) to a 32-bit integer when bitwise operators (such as |) are applied. All bitwise operations are performed on 32-bit integers. This package includes bit twiddling hacks by Sean Eron Anderson and many others.

This package is available in Node.js and Web formats. To use it on the web, simply use the extra_bit global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

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

xbit.count(7);
// ā†’ 3 (111 ā‡’ 3)

xbit.parity(8, 2);
// ā†’ 2 (10,00 ā‡’ 10)

xbit.swap(6, 1, 0);
// ā†’ 5 (110 ā‡’ 101)

xbit.reverse(0xFFFF0000);
// ā†’ 65535 (0x0000FFFF)

xbit.signExtend(15, 4);
// ā†’ -1

Index

PropertyDescription
getGet bits at specified index.
getAsGet bits as per mask.
setSet bits at specified index.
setAsSet bits as per mask.
toggleToggle bits at specified index.
toggleAsToggle bits as per mask.
swapSwap bit sequences at specified indices.
scanFind index of first set bit from LSB.
scanReverseFind index of first set bit from MSB.
countCount bits set.
parityCalculate n-bit parity.
rotateRotate bits by a certain amount.
reverseReverse all bits.
mergeMerge bits as per mask.
interleaveInterleave bits of two int16s.
signExtendSign extend variable bit-width integer.

References

npm.io ORG DOI Coverage Status Test Coverage Maintainability

2.2.48

6 months ago

2.2.46

1 year ago

2.2.47

1 year ago

2.2.44

1 year ago

2.2.45

1 year ago

2.2.42

1 year ago

2.2.43

1 year ago

2.2.41

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.40

1 year ago

2.2.37

2 years ago

2.2.36

2 years ago

2.2.17

2 years ago

2.2.1

2 years ago

2.2.18

2 years ago

2.2.0

2 years ago

2.2.15

2 years ago

2.2.3

2 years ago

2.2.16

2 years ago

2.2.2

2 years ago

2.2.13

2 years ago

2.2.5

2 years ago

2.2.14

2 years ago

2.2.4

2 years ago

2.2.11

2 years ago

2.2.7

2 years ago

2.2.12

2 years ago

2.2.6

2 years ago

2.2.10

2 years ago

2.1.9

2 years ago

2.2.19

2 years ago

2.2.28

2 years ago

2.1.16

2 years ago

2.2.29

2 years ago

2.1.17

2 years ago

2.2.26

2 years ago

2.1.14

2 years ago

2.2.27

2 years ago

2.1.15

2 years ago

2.2.24

2 years ago

2.1.12

2 years ago

2.2.25

2 years ago

2.1.13

2 years ago

2.2.22

2 years ago

2.1.10

2 years ago

2.2.23

2 years ago

2.1.11

2 years ago

2.2.20

2 years ago

2.2.21

2 years ago

2.1.18

2 years ago

2.1.19

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.2.35

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.2.33

2 years ago

2.1.8

2 years ago

2.2.34

2 years ago

2.1.7

2 years ago

2.2.31

2 years ago

2.2.32

2 years ago

2.1.20

2 years ago

2.2.30

2 years ago

2.1.0

2 years ago

2.2.9

2 years ago

2.2.8

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago