Spec 0.16.0
Malagasy Ariary amounts: rules and sources
Formats, reads and converts amounts in Malagasy Ariary (ISO 4217 MGA), writes them in words, and converts old Malagasy francs (FMG).
-
Amounts are numbers from 0 up, whole or decimal, with any number of decimal places: the same range as the number-words module. The spec sets no maximum; a port stops at its largest exact integer:
Number.MAX_SAFE_INTEGER(9 007 199 254 740 991) in JavaScript,PHP_INT_MAXin PHP for whole amounts and 9 007 199 254 740 991 for decimal ones. Amounts beyond that limit, on either side of 0, areOUT_OF_RANGE; anything that is not a finite number isINVALID_TYPE. A port also takes its arbitrary-size integer type when it has one (JavaScriptbigint), read as its exact digits. Shared vectors stay within 9 007 199 254 740 991. A decimal amount is the number value in its shortest exact decimal form:1500.50is1500.5. Every function that takes an amount also takes decimal text (words rule 13: digits, an optional point and decimals, at most 100 characters), read exactly and with no upper limit:formatAriary('1500.25')→1 500,25 Ar. -
Default format:
1 500 Ar. The digits in groups of three separated by no-break spaces (U+00A0), then a no-break space and the symbolAr. Decimals follow a comma, as written, never grouped, rounded or padded:1500.5→1 500,5 Ar,0.25→0,25 Ar. -
Options (
formatAriaryandformatFmg):Option Values Example for 1500.5 groupingspace(default),dot,comma,none1.500,5 Ar,1500,5 Ardecimalcomma(default),dot1 500.5 ArsymbolPositionafter(default),beforeAr 1 500,5currencyDisplaysymbol(default),code1 500,5 MGAThe defaults are the Malagasy way. With
dotgrouping, decimals still follow a comma:1234567.89→1.234.567,89 Ar. A comma is never a thousand separator in Madagascar:grouping: 'comma'anddecimal: 'dot'exist only for text in another convention (1,500.5 Ar).groupinganddecimalmust differ.currencyDisplay: 'code'writes the ISO 4217 code instead of the symbol:MGAfor ariary,MGFfor old francs. Any other value, or the same character for both, isINVALID_TYPE.Negative amounts: a minus sign (
-, U+002D) right before the digits:-1500→-1 500 Ar, andAr -1 500withsymbolPosition: 'before'.formatFmgwrites negatives the same way. Amounts in words (spellAriary) and the FMG conversions stay from 0: a negative there isOUT_OF_RANGE. -
Reading text (
parseAriary,safeParseAriary,tryParseAriary), with thegroupinganddecimaloptions of rule 3 (nosymbolPosition):- Reads a negative amount written as
formatAriarywrites it: the minus sign right before the digits (-1 500 Ar,Ar -1 500,-1500). A sign anywhere else (- 1 500,1 500-,-Ar 1 500) and the plus sign areINVALID_FORMAT. - Accepts the currency as
Ar,MGAorAriary(any case), before or after the amount, or no currency at all, but not on both sides. - Without
grouping, digit groups may be separated by spaces, no-break spaces, narrow no-break spaces (U+202F) or dots, the same separator throughout. Withgrouping, only that separator (spacetakes all three spaces). Every group after the first has three digits. - With
grouping: 'none', no thousand separator is accepted: only digits, then thedecimalseparator and the decimals.parseAriary('1500,5', { grouping: 'none' })→1500.5;1 500and1.500areINVALID_FORMAT. Withdecimal: 'dot'too,1.500is1.5: the strict reading for fields where people type a plain number. - Decimals follow one
decimalseparator, a comma by default:1 500,50 Ar→1500.5,0,5→0.5. By default1,500is 1.5, the Malagasy reading, not fifteen hundred (see “Recorded decisions”). For text in another convention, say so:parseAriary('1,500.50', { grouping: 'comma', decimal: 'dot' })→1500.5. - Rejected with
INVALID_FORMAT: a decimal point other than thedecimaloption, a second decimal separator, a decimal separator with no digit on either side (1,,,5), signs other than that minus, leading zeros, other currencies, and input longer than 329 characters (limits.maxReadLength: the longest textformatAriarywrites for a number, so every formatted amount reads back). - Never a rounded value. An amount a number value cannot hold exactly (too many decimals,
or above the port’s largest exact integer) is
PRECISION_LOSS. The option{ as: 'text' }gives the exact decimal digits instead.
- Reads a negative amount written as
-
In words: the number in words (see the number-words module) followed by
ariary:1500→dimanjato sy arivo ariary,1500.5→dimanjato sy arivo faingo dimy ariary. The wordssystemoption applies (words rule 12):30 000 000in the traditional system →telo safatsiroa ariary. The amount may also be decimal text (words rule 13), read exactly, for amounts a number value cannot hold:'1500.25'→dimanjato sy arivo faingo dimy amby roapolo ariary. Text that is not plain decimal isINVALID_FORMAT. -
Malagasy franc: 1 Ar = 5 FMG.
fmgToAriarydivides by 5 andariaryToFmgmultiplies by 5, both exactly in decimal:7501FMG →1500.2Ar,0.07Ar →0.35FMG (never a binary rounding artefact). Francs may be decimal too. A result a number value cannot hold exactly isPRECISION_LOSS;{ as: 'text' }gives the exact digits.formatFmguses the same layout with the symbolFmg. -
Typing in a field (
formatAmountInput): the text typed so far, grouped asformatAriarygroups it, so a field can format as the user types. Only digits and thedecimalseparator are kept (letters, the symbol and other separators are dropped; a second decimal separator is dropped), leading zeros go (0012→12), a decimal separator typed first becomes0,, and a decimal separator typed last stays:1500,→1 500,. It never throws; nothing typed is''. It takes thegroupinganddecimaloptions of rule 3. -
Options are checked by name: an option that does not exist (
{ symbolPostion: 'after' }) isINVALID_TYPE, never ignored. Text amounts ignore spaces before and after them.
Sources
Section titled “Sources”- Symbol
Ar, nameAriary, symbol spacing: Unicode CLDR 49, localemg(currencies.json, numbers.json). - Space as thousand separator: Ministry of Economy and Finance, Annexe au projet de loi
n° 022/2024 portant loi de finances pour 2025, Tome 3 (amounts such as
12 075 821 312), PDF. - Code
MGA, numeric 969: ISO 4217 list one (SIX, published 2026-09-17), XML. - Franc withdrawn after 2004-12-31: CLDR
currencyData.json
(MG:
MGFuntil 2004-12-31). - 1 ariary = 5 francs: Malagasy Dictionary, ariary (“5,00frs”). The Banky Foiben’i Madagasikara site gave no readable page when checked.
Recorded decisions
Section titled “Recorded decisions”- Symbol after the amount, and negatives (rules 2 and 3). On 2026-11-29 the project lead set
the default to
1 500 Ar(the symbol after the amount, as people write it) and asked for negative amounts with the minus sign right before the digits (-1 500 Ar,Ar -1 500).symbolPosition: 'before'keepsAr 1 500. Confirmed by the project lead on 2026-12-02: negatives stay-1 500 Ar. grouping: 'none'(rules 3 and 4). The project lead asked on 2026-11-30 for a strict mode with no thousand separator, so a field can accept a plain number with one decimal mark (1500,5, or1.5withdecimal: 'dot') and nothing else. It is opt-in; the defaults do not change.- Space or dot, never a comma. CLDR
mggroups thousands with a comma (Ar 1,500). The project lead decided (2026-11-24) that Madagascar uses a space or a dot, which matches the Ministry of Finance documents above. The spec follows the space by default, offers the dot as an option. The symbol now goes after the amount by default (decision of 2026-11-29). - Reading separators. Text pasted from documents uses spaces, no-break spaces or narrow no-break spaces interchangeably, so all three count as the same separator when reading.
- Separator options, Malagasy by default. Every option defaults to the Malagasy way; other conventions are opt-in, so a caller reading text from elsewhere says so instead of the library guessing. Decided by the project lead on 2026-11-26.
- Decimals, with a comma. Amounts take any number of decimals, written after a comma
(
1 500,5 Ar), as in French and Malagasy writing; the dot stays a thousand separator. Reading1,500therefore gives 1.5: in Madagascar it is not ambiguous. Decided by the project lead on 2026-11-26, confirmed 2026-11-27. - No silent rounding. Reading and converting never round: a value a number cannot hold is
PRECISION_LOSS, and the caller chooses the exact text with{ as: 'text' }. Decided by the project lead on 2026-11-27. - Symbol
Fmg. ISO usesMGFand CLDRmghas no symbol for the franc;Fmgis the abbreviation the project lead asked for.
Not provided
Section titled “Not provided”- FMG amounts in words. Not provided.
iraimbilanjanames one franc (1/5 ariary) in English Wikipedia, Malagasy franc and Malagasy Wikipedia, Ariary, and the latter says a franc amount is spoken in ariary (2 500 Fis saiddimanjato). No source spells a whole FMG amount, so the spec adds no FMG words function until one does. Decided by the maintainers on 2026-11-26.
Recorded disagreements
Section titled “Recorded disagreements”- Symbol position. CLDR
mgand the Ministry of Finance documents put the symbol first (Ar 1 500). The spec writes it after the amount by default (decision of 2026-11-29);beforeis an option. - Minor unit. ISO 4217 lists 2 minor units for MGA; CLDR uses 0 digits and amounts are usually written without decimals. Since spec 0.5.0 the spec follows neither limit: amounts take any number of decimals (see “Recorded decisions”).
- Thousand separator. See “Recorded decisions”: CLDR comma vs Ministry of Finance space.