UNPKG

@0xtorch/big-decimal

Version:

An arbitrary precision Decimal type for TypeScript that extends BigInt.

10 lines 456 B
import { removeTrailingZeros } from './removeTrailingZeros'; export const minus = (x, y) => { // adjust the decimals and minus the values. const decimals = Math.max(x.decimals, y.decimals); const valueX = x.value * 10n ** BigInt(decimals - x.decimals); const valueY = y.value * 10n ** BigInt(decimals - y.decimals); const value = valueX - valueY; return removeTrailingZeros({ value, decimals }); }; //# sourceMappingURL=minus.js.map