Skip to main content

numToWords

Converts a number to words.

The optional parameters allow you to choose cardinal or ordinal form, define the threshold for number-to-word conversion, and select a word for representing the value 0.

Parameters

  • NUMBER (number)

    The input number. Can be an integer or a decimal. The function formats the number before performing the number-to-words conversion. To understand this better, see decimal examples.

  • TYPE (string)

    Optional. Whether to convert the number in cardinal or ordinal form. Cardinal numbers describe quantity (e.g. one pot) whereas ordinal numbers signify relative position (e.g. first in line).

    Default: cardinal

  • THRESHOLD (number or string)

    Optional. Defines the maximum value for which the number-to-word conversion occurs. If set to 12, only numbers <= 12 are converted. Set to wordsOnly to convert any number.

    Default: wordsOnly

  • ZERO FORMAT (string)

    Optional. How to express 0 in words. Options: zero, no, none, or a string of your choice.

    Default: zero

Examples

ATL in Script

Result

[[numToWords(3)]]

three

[[numToWords(3, 'ordinal')]]

third

[[numToWords(3, 'ordinal', 0)]]

3rd

[[numToWords(11, '', 12)]]

eleven

[[numToWords(12, '', 12)]]

twelve

[[numToWords(13, '', 12)]]

13

[[numToWords(0, '', '', 'zero')]]

zero

[[numToWords(0, '', '', 'zilch')]]

zilch

Decimal examples

Assume the settings in Settings > Number and Currency are:

Setting

Value

LOCALE

en_US

NUMBER FORMAT

#,##0.##

The NUMBER FORMAT setting ensures number are, by default, formatted to two decimal places with trailing zeros stripped. numToWords applies this formatting before the number-to-words conversion.

ATL in Script

Result

[[numToWords(1.23456789, 'cardinal')]]

one point two three

[[numToWords(1.23456789, 'ordinal')]]

1.23

In both cases, the input number is formatted as 1.23 (as per the NUMBER FORMAT pattern), then converted to words. The second result is 1.23 because decimals can't be expressed in ordinal form.

Important

The default formatting works differently in legacy projects. See Legacy Behaviors.

You can override the project's default number format pattern using formatting functions. However, numToWords does not spell out trailing zeros, even if the number is formatted to display them.

ATL in Script

Result

[[numToWords(precision(125, 3, false), 'cardinal')]]

one hundred twenty-five

Here, the input number is formatted as 125.000 prior to the conversion. Note, however, that the decimal point and three trailing zeros are not included in the output text.

numToWords with locales

A locale is a code representing a language and country. In number formatting, the locale defines which characters are used for decimal and thousand separators in the printed output.

The default locale en_US (English, United States) uses a period (full stop) for the decimal separator and a comma for thousand separators. Other locales use different characters. For example, de_DE (German, Germany) uses a comma for the decimal separator and a period for thousand separators.

numToWords performs its number-to-words conversion of a formatted number regardless of what locale applies; however, the output text is always in English. For example:

ATL in Script

Result

[[numberFormat(500000, '#,##0.00', 'en_US')]]

500,000.00

[[numToWords(numberFormat(500000, '#,##0.00', 'en_US'), 'ordinal')]]

Five hundred thousandth

[[numberFormat(500000, '#,##0.00', 'de_DE')]]

500.000,00

[[numToWords(numberFormat(500000, '#,##0.00', 'de_DE'), 'ordinal')]]

Five hundred thousandth

Important

Calls such as [[numToWords(500.000,00)]] or [[numToWords('500.000,00')]] produce errors. This is because an input literal or string must use a period (full stop) for the decimal separator and a comma for any thousand separators.