Currency Decimal Places: How Many Digits to Round Converted Amounts To

6 min read

Currency Decimal Places: How Many Digits to Round Converted Amounts To

Most currencies use two decimal places, but not all of them. The Japanese yen has none, the Kuwaiti dinar has three, and a converted amount like 18979.92975 JPY has to become a whole number before you can charge it. The number of decimal places a currency uses is called its minor unit exponent, and it is defined per currency in ISO 4217.

If you hardcode toFixed(2) or round(x, 2) everywhere, you will eventually charge a customer 100 times too much in yen or silently lose precision in dinars. This article explains how currency decimal places work, where the common bugs come from, and how to round converted amounts correctly with a short code example.

How many decimal places does a currency have?

A currency's minor unit is the smallest subdivision in everyday use: the cent for USD, the sen for JPY (no longer used in practice), the fils for KWD. The exponent says how many digits follow the decimal point. ISO 4217 lists it for each currency code.

CurrencyCodeDecimal placesSmallest amount
US dollarUSD20.01
EuroEUR20.01
Japanese yenJPY01
South Korean wonKRW01
Kuwaiti dinarKWD30.001
Bahraini dinarBHD30.001

Two things follow from this:

  • Zero-decimal currencies such as JPY and KRW never show fractions. 18980 is a valid price; 18980.00 is merely a formatting choice.
  • Three-decimal currencies such as KWD and BHD need one more digit than most billing systems assume by default.

A small number of codes use even more digits (some unit-of-account codes use four), and a few currencies are listed with a different exponent in different systems. Treat the table you ship as data you review, not a constant you guess. Payment processors and accounting tools also publish their own supported-currency rules, so check what your downstream system expects before you settle on a precision.

Why rounding to two decimals everywhere breaks things

Here are the bugs that appear when two decimals are baked in:

  1. Yen overcharge. A processor that takes amounts in minor units expects 1898 for ¥1,898, not 189800. Multiplying by 100 for every currency inflates yen amounts 100-fold.
  2. Dinar truncation. Rounding 30.7035 KWD to 30.70 throws away fils, so the customer is billed less than the quote, and your books drift from the real conversion.
  3. Fake precision. Showing 18,980.00 JPY suggests a fraction exists. It confuses users and sometimes fails validation downstream.
  4. Double rounding. Rounding the rate, then the amount, then the total each time compounds error. The rounding guide covers why, but the short rule is: keep full precision until the last step, then round once.

Some currencies also have cash rounding rules. Swiss francs, for instance, are commonly rounded to the nearest 0.05 for cash payments, even though the currency has two decimals. That is a point-of-sale rule, not a general rounding rule, so apply it only when you actually handle cash.

A worked example: convert, then round once

Suppose a customer pays 125.50 USD and you want to show the amount in JPY and KWD. The converter returns unrounded results. These numbers are examples, not live rates:

  • 125.50 USD to JPY returns 18979.92975. With 0 decimals, that is 18980 JPY.
  • 100 USD to KWD returns 30.7035. With 3 decimals, that is 30.704 KWD.

The conversion itself is just multiplication: amount × rate. The only thing that depends on the currency is the final rounding step. This is why GetRatesAPI returns exact, unrounded decimal strings: the caller knows the context (display, invoice line, payout) and picks the precision and rounding mode. Rounding on the server would force one answer on every use case.

Implementing it in Python

The pattern is a small table of exponents, a quantize function, and conversion to integer minor units for storage. This example uses Python's decimal module and the /v1/convert endpoint, with the key read from an environment variable.

import os
from decimal import Decimal, ROUND_HALF_UP

import requests

BASE_URL = "https://api.getratesapi.com"
API_KEY = os.environ["GETRATESAPI_KEY"]

# Review this table against ISO 4217 for the currencies you support.
MINOR_UNITS = {
    "USD": 2, "EUR": 2, "GBP": 2,
    "JPY": 0, "KRW": 0,
    "KWD": 3, "BHD": 3,
}


def quantize(amount: str, code: str) -> Decimal:
    digits = MINOR_UNITS[code]  # fail loudly on unknown currencies
    step = Decimal(1).scaleb(-digits)  # 0.01, 1, 0.001, ...
    return Decimal(amount).quantize(step, rounding=ROUND_HALF_UP)


def to_minor_units(amount: Decimal, code: str) -> int:
    return int(amount * (10 ** MINOR_UNITS[code]))


def convert(amount: str, from_code: str, to_code: str) -> Decimal:
    resp = requests.get(
        f"{BASE_URL}/v1/convert",
        params={"from": from_code, "to": to_code, "amount": amount},
        headers={"Authorization": f"ApiKey {API_KEY}"},
        timeout=10,
    )
    resp.raise_for_status()
    raw = resp.json()["converted_amount"]  # exact decimal string
    return quantize(raw, to_code)  # round once, at the end


jpy = convert("125.50", "USD", "JPY")
print(jpy, to_minor_units(jpy, "JPY"))  # e.g. 18980 18980

A few details worth copying:

  • The amount goes in as a string and comes back as a string, so nothing passes through a binary float.
  • MINOR_UNITS[code] raises KeyError for an unknown currency. That is deliberate: a missing entry should stop the request, not default to two decimals.
  • ROUND_HALF_UP matches what most people expect from "round to nearest". Some finance teams require banker's rounding (ROUND_HALF_EVEN) instead. Pick one, document it, and apply it everywhere.

For the same pattern in other languages, see the guides for JavaScript, Java, and Go.

Store minor units, display major units

Once you have a rounded amount, store it as an integer count of minor units: 18980 for ¥18,980, 30704 for 30.704 KWD, 12550 for $125.50. Always store the currency code beside it. Integers avoid representation problems, sum exactly, and match what most payment APIs expect.

Convert back to a decimal only for display, using the same exponent table. Locale formatting libraries handle separators and symbols, but they should receive the correct digit count from your table or from their own ISO data, not a fixed 2.

A few rules that keep this clean:

  • Never store a converted amount without the rate and its as_of timestamp if the number matters later. The invoicing guide explains what to keep.
  • Round each invoice line according to your documented policy, and make sure the total equals the sum of the rounded lines.
  • When adding a fee on top of a conversion, apply the margin at full precision and round afterwards. See adding a markup to live rates.

What about crypto and metals?

Crypto has no ISO 4217 minor unit. Bitcoin is commonly shown with 8 decimals (one satoshi), many tokens use 18 on-chain, but you would rarely display that many. Decide a display precision per asset, and keep the full string value for calculations. Gold and silver (XAU, XAG) are priced per troy ounce and typically shown with two to four decimals depending on context. In all of these cases the principle is the same: the API gives you the exact value, and your application chooses the precision that fits the screen or the ledger.

GetRatesAPI covers about 170 world currencies, gold and silver, and thousands of crypto assets, and the supported codes are listed so you can build your exponent table from the same set you will actually query.

Try it with your own currencies

Build your exponent table, then run a few conversions in the dashboard playground to see the unrounded output next to what your code produces. JPY, KWD and a crypto asset make a good test set. The free plan needs no credit card and includes 500 request units a month, which is plenty for testing your rounding logic. When you are ready for production traffic, compare plans on the pricing page.

All articles →
Currency Decimal Places: Minor Units and Rounding — GetRatesAPI