The function CURRENCY creates a value of the type Currency, which represents an amount, a currency type, and a precision.

This function creates a value of type Currency, it takes as arguments an amount, an optional currency code that specifies which world currency to create, and a precision indicating the size of the denomination. For example, arguments of 1, "USD", and 0 would return a Currency that represents one U.S. dollar, while arguments of 100, "USD", and 2 would represent one-hundred U.S. pennies. While both Currencies represent the same monetary value, the latter will help avoid rounding errors. See Working with Numbers and Currency in Airscript for more details. The List of Currency Codes table at the end of this article lists all valid currency codes, along with a recommended minimum precision.

Declaration

CURRENCY(amount, currency_code, precision) -> currency

Parameters

amount (required, type: number)
An integer representing the amount of the chosen currency_code multiplied by the precision.
currency_code (optional, type: string, default: "USD")
A code specifying which world currency to create. The default is "USD" for U.S. Dollars, "JPY" would represent Japanese Yen. See List of Currency Codes for a complete list of valid codes.
precision (optional, type: number, default: 2)
The precision to be used for the currency, ie. if the precision 3 and amount is 10454, the represented currency would be $10.454

Return Values

currency (type: currency)
The currency with provided, amount, code, and precision.

Examples

While currency is measured using a number, it also requires a unit. One U.S. dollar ("USD") is different from one Canadian dollar ("CAD")

CURRENCY(1, "USD", 0) -> {
amount: 1,
code: "USD",
precision: 0
}
CURRENCY(1, "CAD", 0) -> {
amount: 1,
code: "CAD",
precision: 0
}

In addition to the currency code, providing a precision specifies the smallest denomination the Currency should take into account. For example, one U.S. dollar and one-hundred U.S. pennies represent the same monetary value, however, the latter is a better choice as it will help avoid rounding errors when working with the Currency.

CURRENCY(1, "USD", 0) -> {
amount: 1,
code: "USD",
precision: 0
}
CURRENCY(100, "USD", 2) -> {
amount: 100,
code: "USD",
precision: 2
}

If the currency code and precision are omitted, the default will be to create the currency in U.S. pennies

CURRENCY(100) -> {
amount: 100,
code: "USD",
precision: 2
}

Discussion

It is important to use the Currency type rather than a Number because there are rounding errors when working with decimal Numbers. For example the result of 0.1 + 0.2 is not 0.3 but rather 0.30000000000000004. Performing the same calculation with a precision of 2, will yield the correct result as there will be no decimal places.

10 + 20 -> 30

The table below lists the minimum recommended precision for each currency code in the second column. This number corresponds to the number of decimal places that are typically displayed for that currency. Note that some use cases may require a higher precision if more decimal places are needed.

List of Currency Codes

Code Minimum Recommended Precision Currency Locations listed for this currency
AED 2 United Arab Emirates dirham United Arab Emirates
AFN 2 Afghan afghani Afghanistan
ALL 2 Albanian lek Albania
AMD 2 Armenian dram Armenia
ANG 2 Netherlands Antillean guilder Curaçao (CW), Sint Maarten (SX)
AOA 2 Angolan kwanza Angola
ARS 2 Argentine peso Argentina
AUD 2 Australian dollar Australia, Christmas Island (CX), Cocos (Keeling) Islands (CC), Heard Island and McDonald Islands (HM), Kiribati (KI), Nauru (NR), Norfolk Island (NF), Tuvalu (TV)
AWG 2 Aruban florin Aruba
AZN 2 Azerbaijani manat Azerbaijan
BAM 2 Bosnia and Herzegovina convertible mark Bosnia and Herzegovina
BBD 2 Barbados dollar Barbados
BDT 2 Bangladeshi taka Bangladesh
BGN 2 Bulgarian lev Bulgaria
BHD 3 Bahraini dinar Bahrain
BIF 0 Burundian franc Burundi
BMD 2 Bermudian dollar Bermuda
BND 2 Brunei dollar Brunei
BOB 2 Boliviano Bolivia
BOV 2 Bolivian Mvdol (funds code) Bolivia
BRL 2 Brazilian real Brazil
BSD 2 Bahamian dollar Bahamas
BTN 2 Bhutanese ngultrum Bhutan
BWP 2 Botswana pula Botswana
BYN 2 Belarusian ruble Belarus
BZD 2 Belize dollar Belize
CAD 2 Canadian dollar Canada
CDF 2 Congolese franc Democratic Republic of the Congo
CHE 2 WIR euro (complementary currency) Switzerland
CHF 2 Swiss franc Switzerland, Liechtenstein (LI)
CHW 2 WIR franc (complementary currency) Switzerland
CLF 4 Unidad de Fomento (funds code) Chile
CLP 0 Chilean peso Chile
CNY 2 Chinese yuan China
COP 2 Colombian peso Colombia
COU 2 Unidad de Valor Real (UVR) (funds code) Colombia
CRC 2 Costa Rican colon Costa Rica
CUC 2 Cuban convertible peso Cuba
CUP 2 Cuban peso Cuba
CVE 2 Cape Verdean escudo Cabo Verde
CZK 2 Czech koruna Czechia
DJF 0 Djiboutian franc Djibouti
DKK 2 Danish krone Denmark, Faroe Islands (FO), Greenland (GL)
DOP 2 Dominican peso Dominican Republic
DZD 2 Algerian dinar Algeria
EGP 2 Egyptian pound Egypt
ERN 2 Eritrean nakfa Eritrea
ETB 2 Ethiopian birr Ethiopia
EUR 2 Euro Åland Islands (AX), European Union (EU), Andorra (AD), Austria (AT), Belgium (BE), Cyprus (CY), Estonia (EE), Finland (FI), France (FR), French Southern and Antarctic Lands (TF), Germany (DE), Greece (GR), Guadeloupe (GP), Ireland (IE), Italy (IT), Latvia (LV), Lithuania (LT), Luxembourg (LU), Malta (MT), French Guiana (GF), Martinique (MQ), Mayotte (YT), Monaco (MC), Montenegro (ME), Netherlands (NL), Portugal (PT), Réunion (RE), Saint Barthélemy (BL), Saint Martin (MF), Saint Pierre and Miquelon (PM), San Marino (SM), Slovakia (SK), Slovenia (SI), Spain (ES), Vatican City (VA)
FJD 2 Fiji dollar Fiji
FKP 2 Falkland Islands pound Falkland Islands (pegged to GBP 1:1)
GBP 2 Pound sterling United Kingdom, Isle of Man (IM, see Manx pound), Jersey (JE, see Jersey pound), Guernsey (GG, see Guernsey pound), Tristan da Cunha (SH-TA)
GEL 2 Georgian lari Georgia
GHS 2 Ghanaian cedi Ghana
GIP 2 Gibraltar pound Gibraltar (pegged to GBP 1:1)
GMD 2 Gambian dalasi Gambia
GNF 0 Guinean franc Guinea
GTQ 2 Guatemalan quetzal Guatemala
GYD 2 Guyanese dollar Guyana
HKD 2 Hong Kong dollar Hong Kong
HNL 2 Honduran lempira Honduras
HRK 2 Croatian kuna Croatia
HTG 2 Haitian gourde Haiti
HUF 2 Hungarian forint Hungary
IDR 2 Indonesian rupiah Indonesia
ILS 2 Israeli new shekel Israel
INR 2 Indian rupee India, Bhutan
IQD 3 Iraqi dinar Iraq
IRR 2 Iranian rial Iran
ISK 0 Icelandic króna Iceland
JMD 2 Jamaican dollar Jamaica
JOD 3 Jordanian dinar Jordan
JPY 0 Japanese yen Japan
KES 2 Kenyan shilling Kenya
KGS 2 Kyrgyzstani som Kyrgyzstan
KHR 2 Cambodian riel Cambodia
KMF 0 Comoro franc Comoros
KPW 2 North Korean won North Korea
KRW 0 South Korean won South Korea
KWD 3 Kuwaiti dinar Kuwait
KYD 2 Cayman Islands dollar Cayman Islands
KZT 2 Kazakhstani tenge Kazakhstan
LAK 2 Lao kip Laos
LBP 2 Lebanese pound Lebanon
LKR 2 Sri Lankan rupee Sri Lanka
LRD 2 Liberian dollar Liberia
LSL 2 Lesotho loti Lesotho
LYD 3 Libyan dinar Libya
MAD 2 Moroccan dirham Morocco, Western Sahara
MDL 2 Moldovan leu Moldova
MGA 2[c] Malagasy ariary Madagascar
MKD 2 Macedonian denar North Macedonia
MMK 2 Myanmar kyat Myanmar
MNT 2 Mongolian tögrög Mongolia
MOP 2 Macanese pataca Macau
MRU 929 2[c] Mauritanian ouguiya Mauritania
MUR 2 Mauritian rupee Mauritius
MVR 2 Maldivian rufiyaa Maldives
MWK 2 Malawian kwacha Malawi
MXN 2 Mexican peso Mexico
MXV 2 Mexican Unidad de Inversion (UDI) (funds code) Mexico
MYR 2 Malaysian ringgit Malaysia
MZN 2 Mozambican metical Mozambique
NAD 2 Namibian dollar Namibia
NGN 2 Nigerian naira Nigeria
NIO 2 Nicaraguan córdoba Nicaragua
NOK 2 Norwegian krone Norway, Svalbard and Jan Mayen (SJ), Bouvet Island (BV)
NPR 2 Nepalese rupee Nepal
NZD 2 New Zealand dollar New Zealand, Cook Islands (CK), Niue (NU), Pitcairn Islands (PN; see also Pitcairn Islands dollar), Tokelau (TK)
OMR 3 Omani rial Oman
PAB 2 Panamanian balboa Panama
PEN 2 Peruvian sol Peru
PGK 2 Papua New Guinean kina Papua New Guinea
PHP 2 Philippine peso Philippines
PKR 2 Pakistani rupee Pakistan
PLN 2 Polish złoty Poland
PYG 0 Paraguayan guaraní Paraguay
QAR 2 Qatari riyal Qatar
RON 2 Romanian leu Romania
RSD 2 Serbian dinar Serbia
RUB 2 Russian ruble Russia
RWF 0 Rwandan franc Rwanda
SAR 2 Saudi riyal Saudi Arabia
SBD 2 Solomon Islands dollar Solomon Islands
SCR 2 Seychelles rupee Seychelles
SDG 2 Sudanese pound Sudan
SEK 2 Swedish krona/kronor Sweden
SGD 2 Singapore dollar Singapore
SHP 2 Saint Helena pound Saint Helena (SH-SH), Ascension Island (SH-AC)
SLL 2 Sierra Leonean leone Sierra Leone
SOS 2 Somali shilling Somalia
SRD 2 Surinamese dollar Suriname
SSP 2 South Sudanese pound South Sudan
STN 930 2 São Tomé and Príncipe dobra São Tomé and Príncipe
SVC 2 Salvadoran colón El Salvador
SYP 2 Syrian pound Syria
SZL 2 Swazi lilangeni Eswatini
THB 2 Thai baht Thailand
TJS 2 Tajikistani somoni Tajikistan
TMT 2 Turkmenistan manat Turkmenistan
TND 3 Tunisian dinar Tunisia
TOP 2 Tongan paʻanga Tonga
TRY 2 Turkish lira Turkey
TTD 2 Trinidad and Tobago dollar Trinidad and Tobago
TWD 2 New Taiwan dollar Taiwan
TZS 2 Tanzanian shilling Tanzania
UAH 2 Ukrainian hryvnia Ukraine
UGX 0 Ugandan shilling Uganda
USD 2 United States dollar United States, American Samoa (AS), British Indian Ocean Territory (IO) (also uses GBP), British Virgin Islands (VG), Caribbean Netherlands (BQ – Bonaire, Sint Eustatius and Saba), Ecuador (EC), El Salvador (SV), Guam (GU), Marshall Islands (MH), Federated States of Micronesia (FM), Northern Mariana Islands (MP), Palau (PW), Panama (PA) (as well as Panamanian Balboa), Puerto Rico (PR), Timor-Leste (TL), Turks and Caicos Islands (TC), U.S. Virgin Islands (VI), United States Minor Outlying Islands (UM)
USN 2 United States dollar (next day) (funds code) United States
UYI 0 Uruguay Peso en Unidades Indexadas (URUIURUI) (funds code) Uruguay
UYU 2 Uruguayan peso Uruguay
UYW 4 Unidad previsional Uruguay
UZS 2 Uzbekistan som Uzbekistan
VES 2 Venezuelan bolívar soberano Venezuela
VND 0 Vietnamese đồng Vietnam
VUV 0 Vanuatu vatu Vanuatu
WST 2 Samoan tala Samoa
XAF 0 CFA franc BEAC Cameroon (CM), Central African Republic (CF), Republic of the Congo (CG), Chad (TD), Equatorial Guinea (GQ), Gabon (GA)
XAG . Silver (one troy ounce)  
XAU . Gold (one troy ounce)  
XBA . European Composite Unit (EURCO) (bond market unit)  
XBB . European Monetary Unit (E.M.U.-6) (bond market unit)  
XBC . European Unit of Account 9 (E.U.A.-9) (bond market unit)  
XBD . European Unit of Account 17 (E.U.A.-17) (bond market unit)  
XCD 2 East Caribbean dollar Anguilla (AI), Antigua and Barbuda (AG), Dominica (DM), Grenada (GD), Montserrat (MS), Saint Kitts and Nevis (KN), Saint Lucia (LC), Saint Vincent and the Grenadines (VC)
XDR . Special drawing rights International Monetary Fund
XOF 0 CFA franc BCEAO Benin (BJ), Burkina Faso (BF), Côte d'Ivoire (CI), Guinea-Bissau (GW), Mali (ML), Niger (NE), Senegal (SN), Togo (TG)
XPD . Palladium (one troy ounce)  
XPF 0 CFP franc (franc Pacifique) French territories of the Pacific Ocean: French Polynesia (PF), New Caledonia (NC), Wallis and Futuna (WF)
XPT . Platinum (one troy ounce)  
XSU . SUCRE Unified System for Regional Compensation (SUCRE)
XTS . Code reserved for testing  
XUA . ADB Unit of Account African Development Bank
XXX . No currency  
YER 2 Yemeni rial Yemen
ZAR 2 South African rand Lesotho, Namibia, South Africa
ZMW 2 Zambian kwacha Zambia
ZWL 2 Zimbabwean dollar Zimbabwe

Was this article helpful?

0 out of 0 found this helpful

Articles in this section