https://github.com/dfkaye/safe-math
Safer floating-point math operations in JavaScript that return results we expect, so that 0.1 + 0.2 adds up to 0.3, e.g.
https://github.com/dfkaye/safe-math
Last synced: 5 months ago
JSON representation
Safer floating-point math operations in JavaScript that return results we expect, so that 0.1 + 0.2 adds up to 0.3, e.g.
- Host: GitHub
- URL: https://github.com/dfkaye/safe-math
- Owner: dfkaye
- License: mit
- Created: 2020-11-19T23:38:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-04T01:30:04.000Z (over 4 years ago)
- Last Synced: 2024-12-22T00:36:45.367Z (5 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-math
Safer floating-point math operations in JavaScript that return results we expect, so that 0.1 + 0.2 adds up to **0.3**, e.g., instead of *0.30000000000000004*.
## Documentation
See full details on my blog post at https://dfkaye.com/posts/2020/08/17/safer-math-operations-in-javascript-using-tdd/.
## Install
`npm install @dfkaye/safe-math`
**OR**
`git clone https://github.com/dfkaye/safer-math.git`
## Test
Install dependencies (mocha and chai): `npm install @dfkaye/safe-math --save-dev`
Run: `npm test`
**OR**
Visit the live demo running the browser test suite on my blog at https://dfkaye.com/demos/safe-math-test-suite/.