Implementation of toFixed() that treats floats more like decimals.
Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present problems for accounting- and finance-related software.
Usage:
// Native toFixed has rounding issues(0.615).toFixed(2);// => '0.61'// With accounting-jstoFixed(0.615, 2);// => '0.62' Copy
// Native toFixed has rounding issues(0.615).toFixed(2);// => '0.61'// With accounting-jstoFixed(0.615, 2);// => '0.62'
Float to be treated as a decimal number
Optional
Number of decimal digits to keep
Decide round direction
Implementation of toFixed() that treats floats more like decimals.
Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present problems for accounting- and finance-related software.
Usage: