globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

numberFormatter method returns exponential view of number #750

Closed KhrystynaPopadyuk closed 7 years ago

KhrystynaPopadyuk commented 7 years ago

Hi,

I have numeric value 2e-7. In order to display it to user I use numberFormatter method (minimumIntegerDigits = 1, minimumFractionDigits = 0, maximumFractionDigits = 10) and as result I expect to get something like "0,0000002" but I get "2e-7". How can I avoid exponential notation when format such values?

Thanks

rxaviers commented 7 years ago

Hi, this is a bug and this code needs fix.

rxaviers commented 7 years ago

Instead of using String(number), we needed to use this:

2e-7.toFixed(7)
'0.0000002'
rxaviers commented 7 years ago

This is fixed! Will be release in 1.3.0.