@cosmjs/math
Advanced tools
Comparing version 0.22.3 to 0.23.0-alpha.0
@@ -131,2 +131,11 @@ "use strict"; | ||
} | ||
/** | ||
* a.multiply(b) returns a*b. | ||
* | ||
* We only allow multiplication by unsigned integers to avoid rounding errors. | ||
*/ | ||
multiply(b) { | ||
const product = this.data.atomics.mul(new bn_js_1.default(b.toString())); | ||
return new Decimal(product.toString(), this.fractionalDigits); | ||
} | ||
equals(b) { | ||
@@ -133,0 +142,0 @@ return Decimal.compare(this, b) === 0; |
{ | ||
"name": "@cosmjs/math", | ||
"version": "0.22.3", | ||
"version": "0.23.0-alpha.0", | ||
"description": "Math helpers for blockchain projects", | ||
@@ -40,3 +40,5 @@ "contributors": [ | ||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"", | ||
"build": "shx rm -rf ./build && tsc && yarn move-types && yarn format-types", | ||
"prebuild": "shx rm -rf ./build", | ||
"build": "tsc", | ||
"postbuild": "yarn move-types && yarn format-types", | ||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build", | ||
@@ -51,3 +53,3 @@ "pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js" | ||
}, | ||
"gitHead": "ee205cc5f7b1154f2e8a5149092b19c82672b951" | ||
"gitHead": "5e79100fe341f7f745d28d8d4616912e2122e1ed" | ||
} |
@@ -0,1 +1,2 @@ | ||
import { Uint32, Uint53, Uint64 } from "./integers"; | ||
/** | ||
@@ -34,2 +35,8 @@ * A type for arbitrary precision, non-negative decimals. | ||
minus(b: Decimal): Decimal; | ||
/** | ||
* a.multiply(b) returns a*b. | ||
* | ||
* We only allow multiplication by unsigned integers to avoid rounding errors. | ||
*/ | ||
multiply(b: Uint32 | Uint53 | Uint64): Decimal; | ||
equals(b: Decimal): boolean; | ||
@@ -36,0 +43,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
39164
428