float-equal
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/float-equal package

3.0.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i float-equal

    Weekly Downloads

    564

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    2.59 kB

    Total Files

    4

    Last publish

    Collaborators

    • sindresorhus