decimal-subtract
v1.5.0
Published
Workaround for JavaScript's decimal numbers subtraction problem.
Readme
Decimal Subtract v1.5.0 Documentation
Table of contents
Description
Workaround for JavaScript's decimal numbers subtraction problem.
Installation
For the usage in CJS or ESM run the following command:
npm i decimal-subtractFor script tag usage include the following script:
<!DOCTYPE html>
<html>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/decimal-subtract.min.js"></script>
</body>
</html>Usage example
ESM:
import { decimalSubtract } from 'decimal-subtract'
console.log(1 - 0.55) // 0.44999999999999996
console.log(decimalSubtract(1, 0.55)) // 0.45Classic:
console.log(1 - 0.55) // 0.44999999999999996
console.log(window.decimalSubtract.decimalSubtract(1, 0.55)) // 0.45