Skip to content
GitHub

Modules

Number words

Write any number in Malagasy words, whole or decimal, as written in the standard (official) language, smallest part first.

  • spell(21)iraika amby roapolo
  • spell(2026)enina amby roapolo sy roa arivo
  • spell(1000000)iray tapitrisa
Examples

Result

enina amby roapolo sy roa arivo

JSspell(2026)PHPNumberWords::spell(2026)
Open in the playground →
spell(n, options)Number → Malagasy words
spellOrdinal(n, options)Whole number → ordinal words (rule 14)
parseWords(text, options)Words → number, or throws (rule 15)
safeParseWords(text, opts)Words → number or error code, no throw
tryParseWords(text, options)Words → number, or nothing, never throws

Malagasy reads numbers from the smallest part up. The smaller part joins 10 with ambin'ny, 20–90 and exactly 100 with amby, and 200–900 and every larger group with sy.

2026Said, smallest part first:
  1. enina6
  2. amby
  3. roapolo20
  4. sy
  5. roa arivo2000

enina amby roapolo sy roa arivo

348Said, smallest part first:
  1. valo8
  2. amby
  3. efapolo40
  4. sy
  5. telonjato300

valo amby efapolo sy telonjato

import { spell } from '@mdgascar/number-words';
spell(0); // 'aotra'
spell(11); // "iraika ambin'ny folo"
spell(21); // 'iraika amby roapolo'
spell(101); // 'iraika amby zato'
spell(205); // 'dimy sy roanjato'
spell(348); // 'valo amby efapolo sy telonjato'
spell(1960); // 'enimpolo sy sivinjato sy arivo'
spell(2026); // 'enina amby roapolo sy roa arivo'
spell(10000); // 'iray alina'
spell(280000); // 'valo alina sy roa hetsy'
spell(1000000); // 'iray tapitrisa'

spellOrdinal writes the rank: faha before the number in words, fah before a vowel, and voalohany for 1.

Examples

Result

fahatelo

JSspellOrdinal(3)PHPNumberWords::spellOrdinal(3)
Open in the playground →
import { spellOrdinal } from '@mdgascar/number-words';
spellOrdinal(1); // 'voalohany'
spellOrdinal(2); // 'faharoa'
spellOrdinal(3); // 'fahatelo'
spellOrdinal(4); // 'fahefatra'
spellOrdinal(11); // "fahiraika ambin'ny folo"

parseWords turns the words back into the number. Case and extra spaces do not matter. safeParseWords returns the error instead of throwing, and tryParseWords returns undefined (PHP: safeParse, tryParse).

Examples

Result

2026

JSparseWords('enina amby roapolo sy roa arivo')PHPNumberWords::parse('enina amby roapolo sy roa arivo')->value()
Open in the playground →
import { parseWords } from '@mdgascar/number-words';
parseWords('roa arivo'); // 2000
parseWords('Iraika amby roapolo'); // 21
parseWords('telo faingo dimy'); // 3.5

There is no upper limit in the rules: lavitrisa (10⁹), the largest group word, takes a count of any size. A count before a group word is one phrase joined by amby. Each language stops only where its numbers stop being exact: Number.MAX_SAFE_INTEGER in JavaScript, PHP_INT_MAX in PHP.

Examples

Result

iray lavitrisa

JSspell(1000000000)PHPNumberWords::spell(1000000000)
Open in the playground →
spell(280000000); // 'valopolo amby roanjato tapitrisa'
spell(1000000000); // 'iray lavitrisa'

Malagasy also has a name for every power of ten. It is not used in everyday writing, but learner books list it. Pass system: 'traditional' to use it: each name takes a single digit, 1 to 9, smallest part first, joined by sy. Below 10 000 both systems write the same words, and decimals follow the system you choose.

Power Name Power Name Power Name
10⁴ alina 10⁹ lavitrisa 10¹⁴ safatsiroafaharoa
10⁵ hetsy 10¹⁰ alinkisa 10¹⁵ tsitamboisafaharoa
10⁶ tapitrisa 10¹¹ tsipesimpesenina 10¹⁶ lavitrisafaharoa*
10⁷ safatsiroa 10¹² tsitokotsiforohana 10¹⁷ alinkisafaharoa*
10⁸ tsitamboisa 10¹³ tsihitanoanoa 10¹⁸ tsipesimpeseninafaharoa*

* Derived from the source’s rule: <name>faharoa (“the second”) is that name × 10⁷.

Results computed by the library
CaseCallResult
standardspell(30000000)telopolo tapitrisa
traditionalspell(30000000, { system: 'traditional' })telo safatsiroa
Examples

Result

telo safatsiroa

JSspell(30000000, { system: 'traditional' })PHPNumberWords::spell(30000000, NumberSystem::Traditional)
Open in the playground →
spell(30000000); // 'telopolo tapitrisa'
spell(30000000, { system: 'traditional' }); // 'telo safatsiroa'

The whole part comes first, then faingo (the comma), then the digits after the point read as a whole number. Each zero right after the point is aotra.

Examples

Result

telo faingo efatra ambin'ny folo

JSspell(3.14)PHPNumberWords::spell(3.14)
Open in the playground →
spell(3.14); // "telo faingo efatra ambin'ny folo"
spell(0.5); // 'aotra faingo dimy'
spell(12.75); // "roa ambin'ny folo faingo dimy amby fitopolo"
Input Error code
Not a finite number or text (null, NaN, Infinity) INVALID_TYPE
Text that is not plain decimal ('1 500', '-1', '1e5') INVALID_FORMAT
Below 0 OUT_OF_RANGE
Above the largest exact number of the language OUT_OF_RANGE
parseWords: words that spell does not write INVALID_FORMAT
parseWords: a number too big for the language PRECISION_LOSS
spell(-1); // throws MalagasyIntlError, error.code === 'OUT_OF_RANGE'
spell('1 500'); // throws MalagasyIntlError, 'INVALID_FORMAT'

Negative numbers are not written in words: no source spells one.