JSPM

fixfloat

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q14782F

fix float number bug or round float number

Package Exports

  • fixfloat

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fixfloat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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