DavidFlorin / float-equal

Check if two floats are almost equal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:JavaScript 100.0%