CURRENCY

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

CodeMinimum Recommended PrecisionCurrencyLocations listed for this currency
AED2United Arab Emirates dirhamUnited Arab Emirates
AFN2Afghan afghaniAfghanistan
ALL2Albanian lekAlbania
AMD2Armenian dramArmenia
ANG2Netherlands Antillean guilderCuraçao (CW), Sint Maarten (SX)
AOA2Angolan kwanzaAngola
ARS2Argentine pesoArgentina
AUD2Australian dollarAustralia, Christmas Island (CX), Cocos (Keeling) Islands (CC), Heard Island and McDonald Islands (HM), Kiribati (KI), Nauru (NR), Norfolk Island (NF), Tuvalu (TV)
AWG2Aruban florinAruba
AZN2Azerbaijani manatAzerbaijan
BAM2Bosnia and Herzegovina convertible markBosnia and Herzegovina
BBD2Barbados dollarBarbados
BDT2Bangladeshi takaBangladesh
BGN2Bulgarian levBulgaria
BHD3Bahraini dinarBahrain
BIF0Burundian francBurundi
BMD2Bermudian dollarBermuda
BND2Brunei dollarBrunei
BOB2BolivianoBolivia
BOV2Bolivian Mvdol (funds code)Bolivia
BRL2Brazilian realBrazil
BSD2Bahamian dollarBahamas
BTN2Bhutanese ngultrumBhutan
BWP2Botswana pulaBotswana
BYN2Belarusian rubleBelarus
BZD2Belize dollarBelize
CAD2Canadian dollarCanada
CDF2Congolese francDemocratic Republic of the Congo
CHE2WIR euro (complementary currency)Switzerland
CHF2Swiss francSwitzerland, Liechtenstein (LI)
CHW2WIR franc (complementary currency)Switzerland
CLF4Unidad de Fomento (funds code)Chile
CLP0Chilean pesoChile
CNY2Chinese yuanChina
COP2Colombian pesoColombia
COU2Unidad de Valor Real (UVR) (funds code)Colombia
CRC2Costa Rican colonCosta Rica
CUC2Cuban convertible pesoCuba
CUP2Cuban pesoCuba
CVE2Cape Verdean escudoCabo Verde
CZK2Czech korunaCzechia
DJF0Djiboutian francDjibouti
DKK2Danish kroneDenmark, Faroe Islands (FO), Greenland (GL)
DOP2Dominican pesoDominican Republic
DZD2Algerian dinarAlgeria
EGP2Egyptian poundEgypt
ERN2Eritrean nakfaEritrea
ETB2Ethiopian birrEthiopia
EUR2EuroÅ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)
FJD2Fiji dollarFiji
FKP2Falkland Islands poundFalkland Islands (pegged to GBP 1:1)
GBP2Pound sterlingUnited Kingdom, Isle of Man (IM, see Manx pound), Jersey (JE, see Jersey pound), Guernsey (GG, see Guernsey pound), Tristan da Cunha (SH-TA)
GEL2Georgian lariGeorgia
GHS2Ghanaian cediGhana
GIP2Gibraltar poundGibraltar (pegged to GBP 1:1)
GMD2Gambian dalasiGambia
GNF0Guinean francGuinea
GTQ2Guatemalan quetzalGuatemala
GYD2Guyanese dollarGuyana
HKD2Hong Kong dollarHong Kong
HNL2Honduran lempiraHonduras
HRK2Croatian kunaCroatia
HTG2Haitian gourdeHaiti
HUF2Hungarian forintHungary
IDR2Indonesian rupiahIndonesia
ILS2Israeli new shekelIsrael
INR2Indian rupeeIndia, Bhutan
IQD3Iraqi dinarIraq
IRR2Iranian rialIran
ISK0Icelandic krónaIceland
JMD2Jamaican dollarJamaica
JOD3Jordanian dinarJordan
JPY0Japanese yenJapan
KES2Kenyan shillingKenya
KGS2Kyrgyzstani somKyrgyzstan
KHR2Cambodian rielCambodia
KMF0Comoro francComoros
KPW2North Korean wonNorth Korea
KRW0South Korean wonSouth Korea
KWD3Kuwaiti dinarKuwait
KYD2Cayman Islands dollarCayman Islands
KZT2Kazakhstani tengeKazakhstan
LAK2Lao kipLaos
LBP2Lebanese poundLebanon
LKR2Sri Lankan rupeeSri Lanka
LRD2Liberian dollarLiberia
LSL2Lesotho lotiLesotho
LYD3Libyan dinarLibya
MAD2Moroccan dirhamMorocco, Western Sahara
MDL2Moldovan leuMoldova
MGA2[c]Malagasy ariaryMadagascar
MKD2Macedonian denarNorth Macedonia
MMK2Myanmar kyatMyanmar
MNT2Mongolian tögrögMongolia
MOP2Macanese patacaMacau
MRU9292[c]Mauritanian ouguiya
MUR2Mauritian rupeeMauritius
MVR2Maldivian rufiyaaMaldives
MWK2Malawian kwachaMalawi
MXN2Mexican pesoMexico
MXV2Mexican Unidad de Inversion (UDI) (funds code)Mexico
MYR2Malaysian ringgitMalaysia
MZN2Mozambican meticalMozambique
NAD2Namibian dollarNamibia
NGN2Nigerian nairaNigeria
NIO2Nicaraguan córdobaNicaragua
NOK2Norwegian kroneNorway, Svalbard and Jan Mayen (SJ), Bouvet Island (BV)
NPR2Nepalese rupeeNepal
NZD2New Zealand dollarNew Zealand, Cook Islands (CK), Niue (NU), Pitcairn Islands (PN; see also Pitcairn Islands dollar), Tokelau (TK)
OMR3Omani rialOman
PAB2Panamanian balboaPanama
PEN2Peruvian solPeru
PGK2Papua New Guinean kinaPapua New Guinea
PHP2Philippine pesoPhilippines
PKR2Pakistani rupeePakistan
PLN2Polish złotyPoland
PYG0Paraguayan guaraníParaguay
QAR2Qatari riyalQatar
RON2Romanian leuRomania
RSD2Serbian dinarSerbia
RUB2Russian rubleRussia
RWF0Rwandan francRwanda
SAR2Saudi riyalSaudi Arabia
SBD2Solomon Islands dollarSolomon Islands
SCR2Seychelles rupeeSeychelles
SDG2Sudanese poundSudan
SEK2Swedish krona/kronorSweden
SGD2Singapore dollarSingapore
SHP2Saint Helena poundSaint Helena (SH-SH), Ascension Island (SH-AC)
SLL2Sierra Leonean leoneSierra Leone
SOS2Somali shillingSomalia
SRD2Surinamese dollarSuriname
SSP2South Sudanese poundSouth Sudan
STN9302São Tomé and Príncipe dobra
SVC2Salvadoran colónEl Salvador
SYP2Syrian poundSyria
SZL2Swazi lilangeniEswatini
THB2Thai bahtThailand
TJS2Tajikistani somoniTajikistan
TMT2Turkmenistan manatTurkmenistan
TND3Tunisian dinarTunisia
TOP2Tongan paʻangaTonga
TRY2Turkish liraTurkey
TTD2Trinidad and Tobago dollarTrinidad and Tobago
TWD2New Taiwan dollarTaiwan
TZS2Tanzanian shillingTanzania
UAH2Ukrainian hryvniaUkraine
UGX0Ugandan shillingUganda
USD2United States dollarUnited 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)
USN2United States dollar (next day) (funds code)United States
UYI0Uruguay Peso en Unidades Indexadas (URUIURUI) (funds code)Uruguay
UYU2Uruguayan pesoUruguay
UYW4Unidad previsionalUruguay
UZS2Uzbekistan somUzbekistan
VES2Venezuelan bolívar soberanoVenezuela
VND0Vietnamese đồngVietnam
VUV0Vanuatu vatuVanuatu
WST2Samoan talaSamoa
XAF0CFA franc BEACCameroon (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)
XCD2East Caribbean dollarAnguilla (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 rightsInternational Monetary Fund
XOF0CFA franc BCEAOBenin (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)
XPF0CFP 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.SUCREUnified System for Regional Compensation (SUCRE)
XTS.Code reserved for testing
XUA.ADB Unit of AccountAfrican Development Bank
XXX.No currency
YER2Yemeni rialYemen
ZAR2South African randLesotho, Namibia, South Africa
ZMW2Zambian kwachaZambia
ZWL2Zimbabwean dollarZimbabwe