Skip to content

DavidFlorin/float-equal

 
 

Repository files navigation

float-equal Build Status

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 --save float-equal

Usage

var floatEqual = require('float-equal');

console.log(0.1 + 0.2 === 0.3);
//=> false

console.log(floatEqual(0.1 + 0.2, 0.3));
//=> true

License

MIT © Sindre Sorhus

About

Check if two floats are almost equal

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%