@numio/bigmath 2.2.1 → 2.2.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.
- package/CHANGELOG.md +4 -0
- package/README.md +5 -5
- package/package.json +3 -2
- package/src/IQR/utils.js +3 -0
- package/src/MAD/utils.js +3 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
* **Round Based on Significant Figures:** Control rounding based on the number of significant figures, crucial for scientific and engineering applications.
|
24
24
|
* **Calculate Roots:**
|
25
25
|
* **Calculate Square Root (`sqrt`):** Compute the square root of a number with arbitrary precision. You can also specify the desired precision of the result.
|
26
|
-
*
|
26
|
+
* ****NEW! Calculate Cube Root (`cbrt`):** Determine the cube root of a number with arbitrary precision, allowing you to specify the desired accuracy.
|
27
27
|
|
28
28
|
* **Chain Operations with Pipe:** Simplify complex calculations by chaining arithmetic operations in a readable and intuitive manner.
|
29
29
|
* **Analyze Data Distribution:**
|
@@ -33,12 +33,12 @@
|
|
33
33
|
* **Compare Numbers:**
|
34
34
|
* **Check for Equality (`isEqual`):** Accurately determine if two arbitrary-precision numbers are equal.
|
35
35
|
* **Check if Left is Greater (`isLeftGreater`):** Precisely compare two arbitrary-precision numbers to see if the left operand is greater than the right.
|
36
|
-
*
|
36
|
+
* ****NEW! Check if Left is Greater or Equal (`isLeftGreaterOrEqual`):** Precisely compare two arbitrary-precision numbers to determine if the left operand is greater than or equal to the right.
|
37
37
|
* **Sort Numbers Accurately:** Sort arrays of numbers, including negative and decimal values, in ascending or descending order, correctly handling string representations of numbers that JavaScript's native sort might misinterpret.
|
38
38
|
* **Calculate Central Tendency:** Easily compute the mean (average) of a set of numbers.
|
39
39
|
* **Identify Extremes:** Find the maximum and minimum values within an array of numbers.
|
40
|
-
*
|
41
|
-
*
|
40
|
+
* ****NEW! Calculate Absolute Value (`abs`):** Determine the non-negative value of a number, regardless of its sign.
|
41
|
+
* ****NEW! Convert Number to Another Base (`toBase`):** Seamlessly convert numbers between decimal, hexadecimal (HEX), binary, and octal representations.
|
42
42
|
|
43
43
|
## When is @numio/bigmath essential?
|
44
44
|
|
@@ -431,7 +431,7 @@ Download from NPM - https://www.npmjs.com/package/@numio/bigmath
|
|
431
431
|
|
432
432
|
Download from JSR - https://jsr.io/@numio/bigmath
|
433
433
|
|
434
|
-
Home page - https://
|
434
|
+
Home page - https://numio.deno.dev
|
435
435
|
|
436
436
|
Change log - https://github.com/shpunter/numio-bigmath/blob/main/CHANGELOG.md
|
437
437
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@numio/bigmath",
|
3
3
|
"description": "@numio/bigmath is an arbitrary-precision arithmetic library. It can be used for basic operations with decimal numbers (integers and float)",
|
4
|
-
"version": "2.2.
|
4
|
+
"version": "2.2.2",
|
5
5
|
"keywords": [
|
6
6
|
"precision",
|
7
7
|
"arithmetic",
|
@@ -51,7 +51,8 @@
|
|
51
51
|
"octal",
|
52
52
|
"binary",
|
53
53
|
"decimal",
|
54
|
-
"binary"
|
54
|
+
"binary",
|
55
|
+
"cube root"
|
55
56
|
],
|
56
57
|
"repository": {
|
57
58
|
"type": "git",
|
package/src/IQR/utils.js
CHANGED
@@ -4,6 +4,9 @@ import { PipeInner } from "../pipe/utils.js";
|
|
4
4
|
import { quartileInner } from "../quartile/utils.js";
|
5
5
|
export const MIN_LENGTH_FOR_MAD = 30;
|
6
6
|
export const IQRInner = (array, sigNum = false) => {
|
7
|
+
if (array.length < 3) {
|
8
|
+
throw Error("To calculate IQR you need at least 3 elements");
|
9
|
+
}
|
7
10
|
const { Q1, Q3 } = quartileInner(array);
|
8
11
|
const sub = new PipeInner().sub([Q3, Q1]).calc();
|
9
12
|
if (sigNum) {
|
package/src/MAD/utils.js
CHANGED
@@ -3,6 +3,9 @@ import { quartileInner } from "../quartile/utils.js";
|
|
3
3
|
import { ASC } from "../sort/constants.js";
|
4
4
|
import { sortInner } from "../sort/utils.js";
|
5
5
|
export const MADInner = (array) => {
|
6
|
+
if (array.length < 3) {
|
7
|
+
throw Error("To calculate MAD you need at least 3 elements");
|
8
|
+
}
|
6
9
|
const median = quartileInner(array).Q2;
|
7
10
|
const madArray = array.map((el) => {
|
8
11
|
const [bi, fpe] = new PipeInner().sub([el, median]).calc();
|