extra-bit 2.2.42 → 2.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
The [bit] is a basic unit of information in information theory, computing.<br>
|
|
2
2
|
📦 [Node.js](https://www.npmjs.com/package/extra-bit),
|
|
3
3
|
🌐 [Web](https://www.npmjs.com/package/extra-bit.web),
|
|
4
4
|
📜 [Files](https://unpkg.com/extra-bit/),
|
|
5
5
|
📰 [Docs](https://nodef.github.io/extra-bit/),
|
|
6
6
|
📘 [Wiki](https://github.com/nodef/extra-bit/wiki/).
|
|
7
7
|
|
|
8
|
-
The [bit] is a basic unit of information in information theory, computing. This
|
|
9
|
-
package includes [bit twiddling hacks] by *Sean Eron Anderson* and many others.
|
|
10
|
-
JavaScript converts a `Number` (a *64-bit floating point number*) to a *32-bit*
|
|
11
|
-
*integer* when bitwise operators (such as `|`) are applied. All bitwise operations
|
|
12
|
-
are performed on **32-bit integers**.
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
The concept of a **bit**, which stands for *binary digit*, has been a
|
|
10
|
+
fundamental unit of information in the fields of information theory and
|
|
11
|
+
computing. Bitwise operations are used to manipulate and process data at the bit
|
|
12
|
+
level, and these operations are *crucial for efficient programming* in a variety
|
|
13
|
+
of domains, such as computer graphics and cryptography. JavaScript converts a
|
|
14
|
+
`Number` (a *64-bit floating* *point number*) to a *32-bit integer* when bitwise
|
|
15
|
+
operators (such as `|`) are applied. All bitwise operations are performed on
|
|
16
|
+
**32-bit integers**. This package includes [bit twiddling hacks] by *Sean Eron*
|
|
17
|
+
*Anderson* and many others.
|
|
18
|
+
|
|
19
|
+
This package is available in *Node.js* and *Web* formats. To use it on the web,
|
|
20
|
+
simply use the `extra_bit` global variable after loading with a `<script>`
|
|
21
|
+
tag from the [jsDelivr CDN].
|
|
17
22
|
|
|
18
23
|
> Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).
|
|
19
24
|
|
|
@@ -24,23 +29,23 @@ is exposed as `extra_bit` standalone variable and can be loaded from
|
|
|
24
29
|
<br>
|
|
25
30
|
|
|
26
31
|
```javascript
|
|
27
|
-
const
|
|
28
|
-
// import * as
|
|
29
|
-
// import * as
|
|
32
|
+
const xbit = require('extra-bit');
|
|
33
|
+
// import * as xbit from "extra-bit";
|
|
34
|
+
// import * as xbit from "https://unpkg.com/extra-bit/index.mjs"; (deno)
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
xbit.count(7);
|
|
32
37
|
// → 3 (111 ⇒ 3)
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
xbit.parity(8, 2);
|
|
35
40
|
// → 2 (10,00 ⇒ 10)
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
xbit.swap(6, 1, 0);
|
|
38
43
|
// → 5 (110 ⇒ 101)
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
xbit.reverse(0xFFFF0000);
|
|
41
46
|
// → 65535 (0x0000FFFF)
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
xbit.signExtend(15, 4);
|
|
44
49
|
// → -1
|
|
45
50
|
```
|
|
46
51
|
|