@cosmjs/math
Advanced tools
Comparing version 0.22.2 to 0.22.3
@@ -117,2 +117,16 @@ "use strict"; | ||
} | ||
/** | ||
* a.minus(b) returns a-b. | ||
* | ||
* Both values need to have the same fractional digits. | ||
* The resulting difference needs to be non-negative. | ||
*/ | ||
minus(b) { | ||
if (this.fractionalDigits !== b.fractionalDigits) | ||
throw new Error("Fractional digits do not match"); | ||
const difference = this.data.atomics.sub(new bn_js_1.default(b.atomics)); | ||
if (difference.ltn(0)) | ||
throw new Error("Difference must not be negative"); | ||
return new Decimal(difference.toString(), this.fractionalDigits); | ||
} | ||
equals(b) { | ||
@@ -119,0 +133,0 @@ return Decimal.compare(this, b) === 0; |
{ | ||
"name": "@cosmjs/math", | ||
"version": "0.22.2", | ||
"version": "0.22.3", | ||
"description": "Math helpers for blockchain projects", | ||
@@ -50,3 +50,3 @@ "contributors": [ | ||
}, | ||
"gitHead": "56d635fc6a0986972bb5e9a57625838627c10c7d" | ||
"gitHead": "ee205cc5f7b1154f2e8a5149092b19c82672b951" | ||
} |
@@ -27,2 +27,9 @@ /** | ||
plus(b: Decimal): Decimal; | ||
/** | ||
* a.minus(b) returns a-b. | ||
* | ||
* Both values need to have the same fractional digits. | ||
* The resulting difference needs to be non-negative. | ||
*/ | ||
minus(b: Decimal): Decimal; | ||
equals(b: Decimal): boolean; | ||
@@ -29,0 +36,0 @@ isLessThan(b: Decimal): boolean; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38339
412