1.0.1 • Published 5 years ago

fixfloat v1.0.1

Weekly downloads
9
License
-
Repository
github
Last release
5 years ago

fixfloat

npm npm GitHub license

You can use it to fix the float-number bug in javascript.

const fixfloat = require('fixfloat');

const floatNumber = 0.1 + 0.2; // 0.30000000000000004

fixfloat(floatNumber); // 0.3

You can also use it to round your number.

const fixfloat = require('fixfloat');

const floatNumber = 3456.3456;

fixfloat(floatNumber); // 3456.3
fixfloat(floatNumber, 2); // 3456.35
fixfloat(floatNumber, 1); // 3456.3
fixfloat(floatNumber, 0); // 3456
fixfloat(floatNumber, -1); // 3460
fixfloat(floatNumber, -3); // 3000

Install

npm install fixfloat --save