1.0.1 • Published 11 months ago

tofixed-round-fix v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

toFixed rounding fix polyfill

Polyfill fix for Number.toFixed() method incorrect rounding on certain cases when last significant digit is 5 and fixed length shortens fraction by one digit, as described in original David Kaye post.

Usage

// install
npm install tofixed-round-fix

// import on top of project
import "tofixed-round-fix"

Test cases:

// before
(1.015).toFixed(2) // "1.01"
(63.025).toFixed(2) // "63.02"

// after
(1.015).toFixed(2) // "1.02"
(63.025).toFixed(2) // "63.03"
1.0.1

11 months ago

1.0.0

11 months ago