safe-math-ops
v0.1.3
Published
The goal of this package was to prevent weird decimals from appearing when doing operations (e.g. 9.99 - 8 = 1.9900000000000002 instead of 1.99)
Maintainers
Readme
safe-math-ops
The goal of this package was to prevent weird decimals from appearing. e.g. 9.99 - 8 = 1.9900000000000002 instead of 1.99
Example:
import safeMath from "safe-math-ops";
// Expected output: 1.99
console.log(safeMath.substract([9.99, 8]));
// Expected output: 1.9900000000000002
console.log(9.99 - 8);
// Alternatively, you can use that fixed precision point function that prevent weird decimals from appearing too.
// Expected output: 1.99
console.log(safeMath.format(9.99 - 8));