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

formatMoney broken precision (if bigger then 7) #192

Open arekstryjski opened 6 years ago

arekstryjski commented 6 years ago

I think there is a bug related to formatMoney and precision:

formatMoney(10, { symbol: '฿', precision: 8 });

result in

฿10.00000001

Such a big precision is needed for Bitcoin and possible other cryptocurrencies.

piavgh commented 5 years ago

I have the same problem with formatNumber function. If the precision is 8 (which most cryptocurrency exchanges use), it show a weird number 1 at the end

zdanowiczkonrad commented 5 years ago

I encourage you to use a small lib I built (initially for myself) to handle price formatting in a predictable way: number-currency-format. It is handling the case you mentioned above well (without the dangling one at the end).