3.0.0 • Published 3 years ago

float-equal v3.0.0

Weekly downloads
423
License
MIT
Repository
github
Last release
3 years ago

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