openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.95k stars 528 forks source link

toFixed does not play well with long decimal values. #233

Open eddieddy opened 1 year ago

eddieddy commented 1 year ago

If a long decimal is passed in, javascript already uses Exponential Form. We are getting NAN when passing in: "-0.00000000000000000000003" which is then automatically converted to -3e-23 by javaScript. There is no check before trying to create the exponentialForm on line 219.

image