JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q49273F
  • License ISC

Package Exports

  • floatp
  • floatp/index.js

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 (floatp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

About

Return correct number from a floating point number.

let fp = require('floatp')
v = 0.1 + 0.2 // v: 0.30000000000000004
v = fp(0.1 + 0.2) // v: 0.3

eg2: Array

v = 0.1 + 0.2
ar = [v, v]
ar = fp(ar) // ar: [0.3, 0.3]

eg3: Object (recursive)

v = 0.1 + 0.2
ar = [v, v]
ob = {a:v, b:ar}
ob = fp(ob) // ob: { a: 0.3, b: [ 0.3, 0.3 ] }

eg4: (extra) change precision (default is 12 precision)

v = 3191.379480000001
v = fp(v, 10) // v: 3191.37948

require globally

require('floatp').gb()
floatP()
floatp()
fp() // access globally // global.fp()