fixfloat
v1.0.1
Published
fix float number bug or round float number
Downloads
4
Readme
fixfloat
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