@strong-roots-capital/get-precision
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

get-precision Build status npm version codecov

Count the number of digits to the right of a decimal

This package exists to improve on its predecessors with

  • strong typing
  • support for scientific notation

Install

npm install @strong-roots-capital/get-precision

Use

import getPrecision from '@strong-roots-capital/get-precision'

console.log(getPrecision(0.5))
//=>1

console.log(getPrecision(0.05))
//=>2

console.log(getPrecision(0.00001))
//=>5

console.log(getPrecision(0.00000001))
//=>8

console.log(getPrecision(1.003530591958679e-10))
//=>25

Acknowledgments

Related

Package Sidebar

Install

npm i @strong-roots-capital/get-precision

Weekly Downloads

3

Version

1.0.1

License

ISC

Unpacked Size

6.66 kB

Total Files

6

Last publish

Collaborators

  • amchelle
  • hamroctopus