# Number Formatting

To format numbers on CrossEngage, you should use the `formatDigits` function. The syntax of this formatting function is:

```jsx
{{formatDigits '{
    "propertyName": [Value that should be formatted], 
    "numberDecimals": [Decimals number],
    "decimalSeparator": [Decimal separator], 
    "thousandsSeparator": [Thousand separator],
    "percentage": [Percentage option]
    }'
}}
```

{% hint style="warning" %}
Please note that the formatDigits helper function only works when used with either the `#includeProducts` or `#findProduct` helper function.
{% endhint %}

| Property             | Type    | Description                                                                                                   |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| `propertyName`       | string  | **Required**. The attribute containing the value that is used for formatting. e.g. `[properties.price]`       |
| `numberDecimals`     | integer | **Required**. The number of decimals that is displayed. e.g. `2`                                              |
| `decimalSeparator`   | string  | **Optional**. The string that is used to separate decimals e.g. `,`                                           |
| `thousandsSeparator` | string  | **Optional**. The string that is used to separate thousands e.g. `.`                                          |
| `percentage`         | boolean | **Optional**. This option specifies whether the value should be formatted as a percentage or not. e.g. `true` |

#### Formatting the price of a product extracted from the product feed

Using the helper function `#findProduct`, we search for a particular `sku` and format the result's  `[properties.price]` attribute. We use `2000` as the value of the product's price for the example below.

```jsx
{{formatDigits '{
    "propertyName": "[properties.price]", 
    "numberDecimals": 2,
    "decimalSeparator": ",", 
    "thousandsSeparator": ".",
    "percentage": "false"
    }'
}}
```

Once the function is evaluated, it displays `2.000,00` in the section where it is used in the message.
