Formatting Numbers: roundNum, commaSeparate, numberConvert

Doc Auto Team
Doc Auto Team
  • Updated

This article goes over formatting numbers using the roundNum, commaSeparate, and numberConvert functions.

Number Formatting Functions

Syntax

Description

Example Code

Result

roundNum

Round a number to specific decimal places

${pricePerShare | roundNum:2}

$15.34928 →$15.35

$15 → $15.00

commaSeparate

Separate number with Commas

{numShares | commaSeparate}

10000 → 10,000

numberConvert

Convert integer into text

{numShares | numberConvert}

1000 → one thousand

numberConvert:'ordinalWords'

Convert integer into ordinal text

{123 | numberConvert:'ordinalWords'}

123 → one hundred twenty third

 

Currently numberConvert will only work for integers. They 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