Tolocalestring, Percentages, And Firefox 38
I'm trying to format a percentage to have three significant figures. I'd like a fairly small percentage, something like 1075 / 107175175, to show up as 0.0001%. var x = 1075 / 107
Solution 1:
Have you tried using maximumSignificantDigits: 1?
console.log(x.toLocaleString('en-us', {
style: 'percent', maximumSignificantDigits: 1
}));
Solution 2:
It's a small logical mistake, minimumSignificantDigits
means show at least N numbers, while in your case i think you want to use maximumSignificantDigits
which means show maximun 1 significant digit.
Post a Comment for "Tolocalestring, Percentages, And Firefox 38"