Formatting Numbers: roundNum, commaSeparate, numberConvert

Doc Auto Team
Doc Auto Team
  • Updated

In Athennian, it is possible to format number-type data using the roundNum, commaSeparate, and numberConvert functions. To learn how to code localized number formats in other languages, check out the Localization: Translating Your Code article.



This function rounds a number to the specified number of decimal places

{numberVariable | roundNum:decimalPlace}

Input {pricePerShare| roundNum:2}
Sample Data $15.34928 $15
Output $15.35 $15.00


This function applies commas as digit separators at the appropriate thousandths, millionths, billionths places etc.

{numberVariable | commaSeparate}

Input {numShares | commaSeparate}
Sample Data 100 1000000
Output 100 1,000,000


This function converts integers into text.

{numberVariable | numberConvert}

Input {numShares | numberConvert}
Sample Data 1000
Output One thousand

A variation on this function allows the integers to be converted into ordinal text.

{numberVariable | numberConvert:'ordinalWords'}

Input {numShares | numberConvert:'ordinalWords'}
Sample Data 123
Output One hundred twenty third

numberConvert will only work for integers. It will not fully convert numbers with decimals into text but will just print the integer part of the number. (e.g. 101.23 → one hundred and one). 

You can customize numbers converted to text with numberConvert by stacking text formatting functions. (e.g. {numShares | numberConvert | upper}: 1000 → ONE THOUSAND)
You can learn more about text formatting here: Formatting Text Styles: upper, lower, firstCase

Stacking Number Formatting Functions

The order to stack these functions are:

  1. roundNum

  2. commaSeparate/numberConvert