In a currency exchange rate what is the maximum number of decimal places used? In a currency exchange rate what is the maximum number of decimal places used? sql sql

# In a currency exchange rate what is the maximum number of decimal places used?

I once worked on an international financial C# based package, which had to support numerous currencies, and we supported 6 decimal places. We had a couple of very experienced designers who told us that would be sufficient.

Nowadays, to support the unlikely exchange rate of XBT/VND, you'll need 10 to 14 decimal places

As of 2017-11-20,

``1 XBT = 185,416,429.63 VND1 VND = 0.00000000539327 XBT``

There is not an easy answer on that. The question is what you want to store:

• is it the final currency amount of an invoice?
• or is it maybe the line amount of an document line (e.g. the line amount of an invoice line)?

## Final currency amount

I only know currencies with 2 decimal places but according to this doc from Oracle the ISO standard says 3 decimal places are allowed in a currency. (I couldn't find the ISO document Oracle is mentioning here).

Interesting: SQL Server has a data type `money` and `smallmoney` which supports 4 decimal places. Don't know how they came up with that, maybe because of rounding issues (see below).

## Line amount of an document line

You might want to make sure that you don't run into rounding issues and therefore use more than 3 decimal places where you have a 'sub-amount' of the total amount of a document (e.g. invoice).

Example:

LineQtyPriceDiscountLine AmountLine Amount rounded 2 decimal places
Item A579.993%387.9515387.95
Item B256.123%108.8728108.87
Item C112.193%11.824311.82
Total508.65508.64

We end up having 1 cent rounding difference when we round the line amount to two decimal places. You can play this game with other numbers where you run into differences with more than three decimal places.

The most systems I worked with use different approaches:

• use 5 or more decimal places in the line amount. With 5 decimal places, most if these rounding issues should be soved. I saw ERP systems with 10 decimal places, but I saw this more like an bad application design.
• 'enforce' rounding in the line amount to the currency amount max. decimal places. This makes sence when you want to print the 'Line amount' in the invoice and you don't want to make printed invoices where the rounded line amount does not match up with the total
• make it configurable for the application how many decimal places shall be used.
• adding a 'rouding' line to a document to discount the rounding in case the rounding issues would be to the disadventage of the customer.
• warn the application user when rounding issues occur and ask for how the system shall handle them

It is up to your application design how you want to deal with rounding issues in document lines.