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.

Examples

Result

enina amby roapolo sy roa arivo

JSnumberToWords(2026)PHPNumberWords::fromInt(2026)
Open in the playground →
numberToWords(n)Number → Malagasy words

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.

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

There is no upper limit in the rules: lavitrisa (10⁹), the largest group word, takes a count of any size, written with the same rules. 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

JSnumberToWords(1000000000)PHPNumberWords::fromInt(1000000000)
Open in the playground →
numberToWords(1000000000); // 'iray lavitrisa'

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

JSnumberToWords(3.14)PHPNumberWords::fromFloat(3.14)
Open in the playground →
numberToWords(3.14); // "telo faingo efatra ambin'ny folo"
numberToWords(18.3); // "valo ambin'ny folo faingo telo"
numberToWords(0.5); // 'aotra faingo dimy'
numberToWords(1.05); // 'iray faingo aotra dimy'
numberToWords(0.008); // 'aotra faingo aotra aotra valo'
numberToWords(12.75); // "roa ambin'ny folo faingo dimy amby fitopolo"
numberToWords(1.0); // 'iray' (a whole number has no faingo)

The input is a number value, never text: no spaces, separators or strings. '1 500' is INVALID_TYPE. To read amounts typed by users, use the ariary module.

Input Error code
Not a finite number ('21', NaN, Infinity) INVALID_TYPE
Below 0 OUT_OF_RANGE
Above the largest exact number of the language OUT_OF_RANGE
numberToWords(-1); // throws MdgError, error.code === 'OUT_OF_RANGE'
numberToWords('1 500' as unknown as number); // throws MdgError, 'INVALID_TYPE'
numberToWords(Number.MAX_SAFE_INTEGER + 1); // throws MdgError, 'OUT_OF_RANGE'

Negative numbers, and the old names for 10⁷ and above (safatsiroa, tsitamboisa…), wait for a source or a Malagasy language expert. See Waiting for a source or an expert.