float-equal
v3.0.0
Published
Check if two floats are almost equal
Downloads
929
Maintainers
Readme
float-equal
Check if two floats are almost equal
Due to rounding errors you shouldn't compare floats directly. Instead this module takes an upperbound for rounding errors into consideration.
Install
$ npm install float-equal
Usage
import floatEqual from 'float-equal';
console.log(0.1 + 0.2 === 0.3);
//=> false
console.log(floatEqual(0.1 + 0.2, 0.3));
//=> true