Skip to content

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.

License

Notifications You must be signed in to change notification settings

dfkaye/safe-math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published