big.esm 1.1.1 → 1.1.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +47 -39
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.1.2](https://github.com/dschewchenko/big.esm/compare/v1.1.1...v1.1.2) (2023-05-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * benchmark update and readme notes ([7b8d446](https://github.com/dschewchenko/big.esm/commit/7b8d446be55eb0f0979ab310491e9bb685215753))
7
+
1
8
  ## [1.1.1](https://github.com/dschewchenko/big.esm/compare/v1.1.0...v1.1.1) (2023-05-14)
2
9
 
3
10
 
package/README.md CHANGED
@@ -7,22 +7,20 @@ Library for working with large numbers and fractions using `BigInt`.
7
7
  It provides advanced functionality for performing arithmetic operations with precision and decimal handling.
8
8
  [Documentation](https://dschewchenko.github.io/big.esm/).
9
9
 
10
- 100% test coverage.
10
+ - 100% test coverage.
11
11
 
12
- No dependencies.
12
+ - No dependencies.
13
13
 
14
- No limitations on the size of the numbers, except for the limitations of `BigInt`, so limited by system memory =).
14
+ - No limitations on the size of the numbers, except for the limitations of `BigInt`, so limited by system memory =).
15
15
 
16
- Fully written in TypeScript, so it provides type definitions out of the box.
16
+ - Fully written in TypeScript, so it provides type definitions out of the box.
17
17
 
18
- Tree-shaking is supported.
18
+ - Tree-shaking is supported.
19
19
 
20
20
  Full bundle size(ESM) — 3.12 kB minified and 1.42 kB gzipped.
21
21
  `powBig` operation is half of this size, 1.5kB/0.7kB(minified/gzip),
22
22
  because it's big and reuses most of the operations from `big.esm`.
23
23
 
24
- Full bundle size(UMD) — 3.43 kB minified and 1.57 kB gzipped.
25
-
26
24
  ## Installation
27
25
 
28
26
  Install `big.esm` using npm:
@@ -121,44 +119,54 @@ Compares two `Big` instances. Returns `-1` if `a < b`, `0` if `a == b` and `1` i
121
119
 
122
120
  Compare `big.esm` with `big.js`. 100_000 iterations for each operation.
123
121
 
124
- | Operation | big.esm | big.js | Difference |
125
- |--------------------------|-----------|------------|-----------------|
126
- | init - smallInt | 39.856ms | 22.169ms | -79.78% slower |
127
- | add - smallInt | 24.227ms | 15.125ms | -60.17% slower |
128
- | subtract - smallInt | 22.181ms | 15.094ms | -46.95% slower |
129
- | multiply - smallInt | 22.276ms | 18.538ms | -20.16% slower |
130
- | divide - smallInt | 66.923ms | 179.699ms | 62.76% faster |
131
- | power of 4 - smallInt | 113.714ms | 39.359ms | -188.92% slower |
132
- | init - smallNumber | 44.606ms | 37.136ms | -20.12% slower |
133
- | add - smallNumber | 21.719ms | 21.857ms | 0.63% faster |
134
- | subtract - smallNumber | 21.090ms | 24.064ms | 12.36% faster |
135
- | multiply - smallNumber | 23.246ms | 35.010ms | 33.60% faster |
136
- | divide - smallNumber | 60.102ms | 189.603ms | 68.30% faster |
137
- | power of 4 - smallNumber | 136.611ms | 68.859ms | -98.39% slower |
138
- | init - bigInt | 50.278ms | 36.880ms | -36.33% slower |
139
- | add - bigInt | 27.485ms | 25.402ms | -8.20% slower |
140
- | subtract - bigInt | 27.402ms | 24.622ms | -11.29% slower |
141
- | multiply - bigInt | 33.650ms | 121.126ms | 72.22% faster |
142
- | divide - bigInt | 79.523ms | 602.879ms | 86.81% faster |
143
- | power of 4 - bigInt | 248.514ms | 499.246ms | 50.22% faster |
144
- | init - bigNumber | 55.661ms | 77.789ms | 28.45% faster |
145
- | add - bigNumber | 29.755ms | 47.843ms | 37.81% faster |
146
- | subtract - bigNumber | 29.107ms | 47.313ms | 38.48% faster |
147
- | multiply - bigNumber | 39.976ms | 266.814ms | 85.02% faster |
148
- | divide - bigNumber | 78.278ms | 931.610ms | 91.60% faster |
149
- | power of 4 - bigNumber | 376.169ms | 1132.657ms | 66.79% faster |
122
+ | Operation | big.esm | big.js | Difference |
123
+ |---------------------------|-------------|------------|-----------------|
124
+ | init - smallInt | 40.267ms | 24.225ms | -66.22% slower |
125
+ | add - smallInt | 24.570ms | 16.543ms | -48.52% slower |
126
+ | subtract - smallInt | 22.152ms | 16.455ms | -34.63% slower |
127
+ | multiply - smallInt | 23.394ms | 25.183ms | 7.10% faster |
128
+ | divide - smallInt | 68.486ms | 232.593ms | 70.56% faster |
129
+ | power of 4 - smallInt | 124.721ms | 63.314ms | -96.99% slower |
130
+ | square root - smallInt | 5608.635ms | 1489.536ms | -276.54% slower |
131
+ | init - smallNumber | 43.917ms | 38.125ms | -15.19% slower |
132
+ | add - smallNumber | 22.342ms | 26.888ms | 16.91% faster |
133
+ | subtract - smallNumber | 21.692ms | 27.138ms | 20.07% faster |
134
+ | multiply - smallNumber | 27.452ms | 56.488ms | 51.40% faster |
135
+ | divide - smallNumber | 62.497ms | 318.407ms | 80.37% faster |
136
+ | power of 4 - smallNumber | 153.008ms | 156.773ms | 2.40% faster |
137
+ | square root - smallNumber | 5557.749ms | 1558.616ms | -256.58% slower |
138
+ | init - bigInt | 50.074ms | 36.019ms | -39.02% slower |
139
+ | add - bigInt | 27.391ms | 24.467ms | -11.95% slower |
140
+ | subtract - bigInt | 27.009ms | 24.022ms | -12.43% slower |
141
+ | multiply - bigInt | 33.851ms | 120.812ms | 71.98% faster |
142
+ | divide - bigInt | 77.744ms | 714.170ms | 89.11% faster |
143
+ | power of 4 - bigInt | 248.630ms | 498.119ms | 50.09% faster |
144
+ | square root - bigInt | 16917.234ms | 5955.270ms | -184.07% slower |
145
+ | init - bigNumber | 60.159ms | 85.812ms | 29.89% faster |
146
+ | add - bigNumber | 33.340ms | 56.803ms | 41.31% faster |
147
+ | subtract - bigNumber | 34.255ms | 54.496ms | 37.14% faster |
148
+ | multiply - bigNumber | 50.376ms | 452.010ms | 88.86% faster |
149
+ | divide - bigNumber | 80.627ms | 1376.583ms | 94.14% faster |
150
+ | power of 4 - bigNumber | 553.183ms | 2005.740ms | 72.42% faster |
151
+ | square root - bigNumber | 17023.515ms | 5104.271ms | -233.52% slower |
152
+
153
+ Note 1: Square root is slower because it uses Newton's method with variable root(quadratic, cubic, etc.ій) and high precision.
154
+ The more precise the result, the more iterations are required.
155
+
156
+ Node 2: On small numbers big.esm is slower because it uses bigint, which is slower on initialization.
157
+ And each operation returns a new instance of Big, without mutating the original instance.
150
158
 
151
159
  #### Test data:
152
160
 
153
161
  ```js
154
- const smallIntA = 123;
155
- const smallIntB = 456;
156
- const smallNumberA = 123.456;
157
- const smallNumberB = 789.012;
162
+ const smallIntA = 12345;
163
+ const smallIntB = 45678;
164
+ const smallNumberA = 12345.67809;
165
+ const smallNumberB = 78901.23456;
158
166
  const bigIntA = "12345678901234567890";
159
167
  const bigIntB = "67890123456789012345";
160
- const bigNumberA = "12345678901234567890.1234567890";
161
- const bigNumberB = "67890123456789012345.6789012345";
168
+ const bigNumberA = "12345678901234567890.12345678901234567890"
169
+ const bigNumberB = "67890123456789012345.67890123456789012345";
162
170
  ```
163
171
 
164
172
  Benchmarked on MacBook Pro M1 2021.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "big.esm",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A small, fast JavaScript library for arbitrary-precision decimal arithmetic.",
5
5
  "type": "module",
6
6
  "scripts": {