Skip to main content

round

Rounds a number to a specific number of decimal places.

This function changes the input number's actual value. To change the number's display value — that is, how it appears in the output text — but leave its actual value unchanged, use precision instead.

Parameters

  • NUMBER (number)

    The number to round.

  • DECIMAL PLACES (number or string)

    Optional. The number of decimal places.

    Another option is to set the parameter to inherit. This ensures that the number of decimal places is taken from the input number's existing display format. See Examples using Inherit.

    Default: inherit

  • STRIP TRAILING ZEROS (Boolean or string)

    Optional. Whether to strip trailing zeros from the result (true) or leave them in place (false).

    A third option is to set the parameter to inherit. This ensures that the decision to strip or retain trailing zeros is based on the input number's existing display format. See Examples using Inherit.

    Default: inherit

Important

The default values above are the system defaults. You can change these defaults in your project's Settings view. See Settings > Number and Currency for guidance.

Examples

Assume the settings in Settings > Number and Currency are:

Setting

Value

DECIMAL PLACES FOR ROUNDING

2

STRIP TRAILING ZEROS FOR ROUNDING

true

When the optional parameters are unspecified, the project settings apply.

ATL in Script

Result

[[round(238967.457)]]

238,967.46

Note

Half-up rounding applies automatically.

Use the second parameter to define the number of decimal places.

ATL in Script

Result

[[round(238967.457, 0)]]

238,967

[[round(238967.457, 1)]]

238,967.5

You can round to a negative number of decimal places.

ATL in Script

Result

[[round(238967.457, -3)]]

239,000

[[round(238967.457, -4)]]

240,000

Set the third parameter to false to include trailing zeros.

ATL in Script

Result

[[round(238967, 2)]]

238,967

[[round(238967, 2, false)]]

238,967.00

Examples using inherit

These examples show use of inherit in the optional parameters.

Assume the settings in Settings > Number and Currency are:

Setting

Value

NUMBER FORMAT

#,###.000

DECIMAL PLACES FOR ROUNDING

2

STRIP TRAILING ZEROS FOR ROUNDING

true

DECIMAL PLACES

When DECIMAL PLACES = inherit, the number of decimal places is inherited from the number's existing display format. All numbers have a default display format, defined by the project's NUMBER FORMAT setting.

ATL In Script

Result

[[round(1.2345, 'inherit')]]

1.235

Note

In this example, NUMBER FORMAT = #,###.000, so the number is rounded to three decimal places. Any trailing zeros — not applicable in this case — are retained.

However, if the number is already formatted by a function such as numberFormat, the number of decimal places is inherited from the formatting applied by that function.

ATL In Script

Result

[[round(numberFormat(1.2345,'#,###.0'), 'inherit')]]

1.2

Note

In this example, the number is already formatted by numberFormat. The round function inherits this formatting (#,##0.#), and rounds the number to one decimal place.

STRIP TRAILING ZEROS

The same principles described above apply to the STRIP TRAILING ZEROS parameter:

ATL In Script

Result

[[round(1001.1, 'inherit', 'inherit')]]

1,001.100

[[round(numberFormat(1001.1,'#,###.00'),'inherit', 'inherit')]]

1,001.10