bigdecimal.js
Advanced tools
+97
-18
@@ -465,3 +465,3 @@ /** | ||
| */ | ||
| add(augend: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| add(augend: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -480,3 +480,3 @@ * Returns a `BigDecimal` whose value is `(this - subtrahend)`, | ||
| */ | ||
| subtract(subtrahend: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| subtract(subtrahend: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -492,3 +492,3 @@ * Returns a `BigDecimal` whose value is <code>(this × | ||
| */ | ||
| multiply(multiplicand: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| multiply(multiplicand: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -512,3 +512,3 @@ * Returns a `BigDecimal` whose value is `(this / divisor)`, | ||
| */ | ||
| divide(divisor: BigDecimal | BigInt | number | string, scale?: number, roundingMode?: RoundingMode): BigDecimal; | ||
| divide(divisor: BigDecimal | bigint | number | string, scale?: number, roundingMode?: RoundingMode): BigDecimal; | ||
| /** | ||
@@ -526,3 +526,3 @@ * Returns a `BigDecimal` whose value is `(this / | ||
| */ | ||
| divideWithMathContext(divisor: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| divideWithMathContext(divisor: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -548,3 +548,3 @@ * Returns a `BigDecimal` whose value is the integer part | ||
| */ | ||
| divideToIntegralValue(divisor: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| divideToIntegralValue(divisor: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -570,7 +570,7 @@ * Returns a `BigDecimal` whose value is `(this % divisor)`, with rounding according to the context settings. | ||
| * rounding mode is `UNNECESSARY`, or `mc.precision` | ||
| * > 0 and the result of {`this.divideToIntegralValue(divisor)` would | ||
| * > 0 and the result of `this.divideToIntegralValue(divisor)` would | ||
| * require a precision of more than `mc.precision` digits. | ||
| * @see {@link divideToIntegralValue} | ||
| */ | ||
| remainder(divisor: BigDecimal | BigInt | number | string, mc?: MathContext): BigDecimal; | ||
| remainder(divisor: BigDecimal | bigint | number | string, mc?: MathContext): BigDecimal; | ||
| /** | ||
@@ -590,2 +590,8 @@ * Compares this `BigDecimal` with the specified | ||
| * | ||
| * ``` | ||
| * Big("2.0" ).divide(Big(3), undefined, HALF_UP) // which evaluates to 0.7 | ||
| * | ||
| * Big("2.00").divide(Big(3), undefined, HALF_UP) // which evaluates to 0.67. | ||
| *``` | ||
| * | ||
| * @param value to which this `BigDecimal` is | ||
@@ -626,3 +632,3 @@ * to be compared. | ||
| */ | ||
| divideAndRemainder(divisor: BigDecimal | BigInt | number | string, mc?: MathContext): [BigDecimal, BigDecimal]; | ||
| divideAndRemainder(divisor: BigDecimal | bigint | number | string, mc?: MathContext): [BigDecimal, BigDecimal]; | ||
| /** | ||
@@ -635,4 +641,4 @@ * Returns an approximation to the square root of `this` | ||
| * always within one ulp of the exact decimal value for the | ||
| * precision in question. If the rounding mode is {@link | ||
| * RoundingMode.HALF_UP}, {@link RoundingMode.HALF_DOWN}, | ||
| * precision in question. If the rounding mode is | ||
| * {@link RoundingMode.HALF_UP}, {@link RoundingMode.HALF_DOWN}, | ||
| * or {@link RoundingMode.HALF_EVEN}, the | ||
@@ -686,3 +692,3 @@ * result is within one half an ulp of the exact decimal value. | ||
| */ | ||
| unscaledValue(): BigInt; | ||
| unscaledValue(): bigint; | ||
| /** | ||
@@ -731,5 +737,78 @@ * Returns the <i>scale</i> of this `BigDecimal`. If zero | ||
| * less than, equal to, or greater than `val`. | ||
| * @see {@link sameValue} | ||
| * @see {@link greaterThan} | ||
| * @see {@link greaterThanOrEquals} | ||
| * @see {@link lowerThan} | ||
| * @see {@link lowerThanOrEquals} | ||
| */ | ||
| compareTo(val: BigDecimal | BigInt | number | string): number; | ||
| compareTo(val: BigDecimal | bigint | number | string): number; | ||
| /** | ||
| * Alias for `compareTo(val) === 0`. | ||
| * Consider using {@link equals} in case the scale needs to be considered. | ||
| * @returns true if the value is the same as `val` | ||
| * @see {@link equals} | ||
| * @see {@link compareTo} | ||
| */ | ||
| sameValue(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * Alias for `compareTo(val) > 0`. | ||
| * | ||
| * @param val value to which this `BigDecimal` is to be compared. | ||
| * This value will be converted to a `BigDecimal` before the operation. | ||
| * See the {@link Big | constructor} to learn more about the conversion. | ||
| * @returns true if the value is greater than `val` | ||
| * @see {@link compareTo} | ||
| * @alias {@link gt} | ||
| */ | ||
| greaterThan(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * @alias {@link greaterThan} | ||
| */ | ||
| gt(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * Alias for `compareTo(val) >= 0`. | ||
| * | ||
| * @param val value to which this `BigDecimal` is to be compared. | ||
| * This value will be converted to a `BigDecimal` before the operation. | ||
| * See the {@link Big | constructor} to learn more about the conversion. | ||
| * @returns true if the value is greater than or equals to `val` | ||
| * @see {@link compareTo} | ||
| * @alias {@link gte} | ||
| */ | ||
| greaterThanOrEquals(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * @alias {@link greaterThanOrEquals} | ||
| */ | ||
| gte(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * Alias for `compareTo(val) < 0`. | ||
| * | ||
| * @param val value to which this `BigDecimal` is to be compared. | ||
| * This value will be converted to a `BigDecimal` before the operation. | ||
| * See the {@link Big | constructor} to learn more about the conversion. | ||
| * @returns true if the value is lower than `val` | ||
| * @see {@link compareTo} | ||
| * @alias {@link lt} | ||
| */ | ||
| lowerThan(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * @alias {@link lowerThan} | ||
| */ | ||
| lt(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * Alias for `compareTo(val) <= 0`. | ||
| * | ||
| * @param val value to which this `BigDecimal` is to be compared. | ||
| * This value will be converted to a `BigDecimal` before the operation. | ||
| * See the {@link Big | constructor} to learn more about the conversion. | ||
| * @returns true if the value is lower than or equals to `val` | ||
| * @see {@link compareTo} | ||
| * @alias {@link lte} | ||
| */ | ||
| lowerThanOrEquals(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * @alias {@link lowerThanOrEquals} | ||
| */ | ||
| lte(val: BigDecimal | bigint | number | string): boolean; | ||
| /** | ||
| * Converts this BigDecimal to number. | ||
@@ -799,3 +878,3 @@ * @return number for of this BigDecimal | ||
| * * An `RangeError` exception is thrown if | ||
| * * `abs(n)` > 999999999} | ||
| * * `abs(n)` > 999999999 | ||
| * * `mc.precision == 0` and `n < 0` | ||
@@ -1051,3 +1130,3 @@ * * `mc.precision > 0` and `n` has more than | ||
| */ | ||
| toBigInt(): BigInt; | ||
| toBigInt(): bigint; | ||
| /** | ||
@@ -1061,7 +1140,7 @@ * Converts this `BigDecimal` to a `BigInt`, | ||
| */ | ||
| toBigIntExact(): BigInt; | ||
| toBigIntExact(): bigint; | ||
| } | ||
| interface BigDecimalConstructor { | ||
| (n: BigDecimal | BigInt | number | string, scale?: number, mc?: MathContext): BigDecimal; | ||
| new (n: BigDecimal | BigInt | number | string, scale?: number, mc?: MathContext): BigDecimal; | ||
| (n: BigDecimal | bigint | number | string, scale?: number, mc?: MathContext): BigDecimal; | ||
| new (n: BigDecimal | bigint | number | string, scale?: number, mc?: MathContext): BigDecimal; | ||
| } | ||
@@ -1068,0 +1147,0 @@ /** |
+18
-18
| { | ||
| "name": "bigdecimal.js", | ||
| "version": "1.2.0", | ||
| "version": "1.3.0", | ||
| "description": "A BigDecimal implementation with native BigInts", | ||
@@ -62,20 +62,20 @@ "exports": { | ||
| "devDependencies": { | ||
| "@istanbuljs/nyc-config-typescript": "~1.0.2", | ||
| "@typescript-eslint/eslint-plugin": "~5.10.2", | ||
| "@typescript-eslint/parser": "~5.10.2", | ||
| "benchmark": "~2.1.4", | ||
| "big.js": "~6.1.1", | ||
| "bigdecimal": "~0.6.1", | ||
| "bignumber.js": "^9.0.2", | ||
| "chai": "~4.3", | ||
| "decimal.js": "^10.3.1", | ||
| "eslint": "~8.8.0", | ||
| "mocha": "~9.2.0", | ||
| "nyc": "~15.1.0", | ||
| "rimraf": "~3.0.2", | ||
| "source-map-support": "~0.5.21", | ||
| "ts-node": "~10.4.0", | ||
| "typedoc": "~0.22.11", | ||
| "typescript": "~4.5.5" | ||
| "@istanbuljs/nyc-config-typescript": "^1.0.2", | ||
| "@typescript-eslint/eslint-plugin": "^5.38.1", | ||
| "@typescript-eslint/parser": "^5.38.1", | ||
| "benchmark": "^2.1.4", | ||
| "big.js": "^6.2.1", | ||
| "bigdecimal": "^0.6.1", | ||
| "bignumber.js": "^9.1.0", | ||
| "chai": "^4.3", | ||
| "decimal.js": "^10.4.1", | ||
| "eslint": "^8.24.0", | ||
| "mocha": "^9.2.0", | ||
| "nyc": "^15.1.0", | ||
| "rimraf": "^3.0.2", | ||
| "source-map-support": "^0.5.21", | ||
| "ts-node": "^10.9.1", | ||
| "typedoc": "^0.23.15", | ||
| "typescript": "^4.8.4" | ||
| } | ||
| } |
+18
-18
@@ -97,12 +97,12 @@ # BigDecimal.js | ||
| * Test Machine: | ||
| * M1 2021 MacBook Pro | ||
| * 32 GB Ram | ||
| * MacOS Monterey 12.2.1 | ||
| * Update Date: June 16th 2022 | ||
| * M1 2021 MacBook Air | ||
| * 16 GB Ram | ||
| * MacOS Monterey 12.4 | ||
| * Update Date: September 30th 2022 | ||
| * Library versions used: | ||
| * big.js 6.1.1 | ||
| * (this library) bigdecimal.js 1.1.3 | ||
| * big.js 6.2.1 | ||
| * (this library) bigdecimal.js 1.2.0 | ||
| * bigdecimal 0.6.1 | ||
| * bignumber.js: 9.0.2 | ||
| * decimal.js:10.3.1 | ||
| * bignumber.js: 9.1.0 | ||
| * decimal.js:10.4.1 | ||
@@ -116,12 +116,12 @@ * Each operation is run with fixed set of decimal numbers composed of both simple and complex numbers. | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | Constructor | 44,267 ( - ) | 38,737 (<span style="color:red">-12%</span>) | 42,046 (<span style="color:red">-5%</span>) | 42,947 (<span style="color:red">-3%</span>) | 2,819 (<span style="color:red">-94%</span>) | | ||
| | Add | 80,650 ( - ) | 18,308 (<span style="color:red">-77%</span>) | 101,400 (<span style="color:green">**+26%**</span>) | 61,821 (<span style="color:red">-23%</span>) | 90 (<span style="color:red">-100%</span>) | | ||
| | Subtract | 74,916 ( - ) | 17,771 (<span style="color:red">-76%</span>) | 96,674 (<span style="color:green">**+29%**</span>) | 58,300 (<span style="color:red">-22%</span>) | 92 (<span style="color:red">-100%</span>) | | ||
| | Multiply | 498,855 ( - ) | 33,907 (<span style="color:red">-93%</span>) | 27,577 (<span style="color:red">-94%</span>) | 84,791 (<span style="color:red">-83%</span>) | 2,735 (<span style="color:red">-99%</span>) | | ||
| | Divide | 15,874 ( - ) | 1,146 (<span style="color:red">-93%</span>) | 12,482 (<span style="color:red">-21%</span>) | 14,581 (<span style="color:red">-8%</span>) | 672 (<span style="color:red">-96%</span>) | | ||
| | Remainder | 10,174 ( - ) | 3,992 (<span style="color:red">-61%</span>) | 14,122 (<span style="color:green">**+39%**</span>) | 23,369 (<span style="color:green">**+130%**</span>) | 2,562 (<span style="color:red">-75%</span>) | | ||
| | Positive pow | 28,110 ( - ) | 25 (<span style="color:red">-100%</span>) | 128 (<span style="color:red">-100%</span>) | 3,847 (<span style="color:red">-86%</span>) | 6 (<span style="color:red">-100%</span>) | | ||
| | Negative pow | 5,178 ( - ) | 21 (<span style="color:red">-100%</span>) | 122 (<span style="color:red">-98%</span>) | 2,147 (<span style="color:red">-59%</span>) | 282 (<span style="color:red">-95%</span>) | | ||
| | Abs | 801,274 ( - ) | 1,520,066 (<span style="color:green">**+90%**</span>) | 957,966 (<span style="color:green">**+20%**</span>) | 391,313 (<span style="color:red">-51%</span>) | 14,215 (<span style="color:red">-98%</span>) | | ||
| | Compare | 557,156 ( - ) | 1,235,655 (<span style="color:green">**+122%**</span>) | 801,622 (<span style="color:green">**+44%**</span>) | 431,935 (<span style="color:red">-22%</span>) | 1,034,051 (<span style="color:green">**+86%**</span>) | | ||
| | Constructor | 44,023 ( - ) | 38,837 (<span style="color:red">-12%</span>) | 42,904 (<span style="color:red">-3%</span>) | 42,332 (<span style="color:red">-4%</span>) | 2,867 (<span style="color:red">-93%</span>) | | ||
| | Add | 80,680 ( - ) | 18,565 (<span style="color:red">-77%</span>) | 102,628 (<span style="color:green">**+27%**</span>) | 60,988 (<span style="color:red">-24%</span>) | 89 (<span style="color:red">-100%</span>) | | ||
| | Subtract | 74,621 ( - ) | 18,297 (<span style="color:red">-75%</span>) | 97,269 (<span style="color:green">**+30%**</span>) | 56,907 (<span style="color:red">-24%</span>) | 89 (<span style="color:red">-100%</span>) | | ||
| | Multiply | 503,718 ( - ) | 33,486 (<span style="color:red">-93%</span>) | 27,603 (<span style="color:red">-95%</span>) | 81,700 (<span style="color:red">-84%</span>) | 2,720 (<span style="color:red">-99%</span>) | | ||
| | Divide | 15,352 ( - ) | 1,129 (<span style="color:red">-93%</span>) | 12,169 (<span style="color:red">-21%</span>) | 14,022 (<span style="color:red">-9%</span>) | 679 (<span style="color:red">-96%</span>) | | ||
| | Remainder | 9,557 ( - ) | 3,916 (<span style="color:red">-59%</span>) | 14,052 (<span style="color:green">**+47%**</span>) | 22,538 (<span style="color:green">**+136%**</span>) | 2,605 (<span style="color:red">-73%</span>) | | ||
| | Positive pow | 27,710 ( - ) | 25 (<span style="color:red">-100%</span>) | 121 (<span style="color:red">-100%</span>) | 3,685 (<span style="color:red">-87%</span>) | 6 (<span style="color:red">-100%</span>) | | ||
| | Negative pow | 4,783 ( - ) | 21 (<span style="color:red">-100%</span>) | 117 (<span style="color:red">-98%</span>) | 2,063 (<span style="color:red">-57%</span>) | 277 (<span style="color:red">-94%</span>) | | ||
| | Abs | 771,310 ( - ) | 1,329,070 (<span style="color:green">**+72%**</span>) | 904,043 (<span style="color:green">**+17%**</span>) | 339,619 (<span style="color:red">-56%</span>) | 13,737 (<span style="color:red">-98%</span>) | | ||
| | Compare | 536,627 ( - ) | 1,180,043 (<span style="color:green">**+120%**</span>) | 764,960 (<span style="color:green">**+43%**</span>) | 393,814 (<span style="color:red">-27%</span>) | 1,010,649 (<span style="color:green">**+88%**</span>) | | ||
@@ -128,0 +128,0 @@ [npm-image]: https://img.shields.io/npm/v/bigdecimal.js.svg |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
440270
2.12%9536
2.95%1
Infinity%