All Products
Search
Document Center

Performance Testing:Arithmetic operations

Last Updated:Mar 11, 2026

Performance Testing (PTS) provides built-in arithmetic operations for dynamic value computation during test execution.

Operation categories

CategoryOperationsDefault decimal handling
Basic arithmeticAddition, subtraction, multiplication, division (basic)Rounds to 2 decimal places (round-half-up)
Advanced divisionDivision (advanced)Configurable decimal places and rounding mode
Roundingscale() functionConfigurable decimal places and rounding mode

Basic arithmetic

Addition, subtraction, multiplication, and division (basic) round decimal results to 2 decimal places by default, using the round-half-up method (ROUND_HALF_UP, mode 4).

ExpressionRaw resultRounded result
1.234 * 56.1706.17
1 / 50.2000.20

Control decimal precision

Division (advanced) and the scale() function let you control the number of decimal places and the rounding behavior. Both accept two parameters: the number of decimal places to retain and the rounding mode.

scale() syntax

scale(<decimal_places>, <round_mode>)
ParameterDescription
decimal_placesNumber of decimal places to retain.
round_modeRounding mode identifier (0--6). See the Rounding modes section below.

Example: scale(1, 2) retains 1 decimal place using ROUND_CEILING mode (round_mode=2).

Rounding modes

PTS supports seven rounding modes, aligned with the Java BigDecimal rounding constants.

Note

The following examples assume 2 decimal places.

round_modeJava constantDirectionPositive exampleNegative example
0ROUND_UPAway from zero1.234 → 1.24-1.234 → -1.24
1ROUND_DOWNTowards zero (truncate)1.234 → 1.23-1.234 → -1.23
2ROUND_CEILINGTowards positive infinity1.234 → 1.24-1.234 → -1.23
3ROUND_FLOORTowards negative infinity1.234 → 1.23-1.234 → -1.24
4ROUND_HALF_UPNearest neighbor; if equidistant, away from zero. If both neighbors are equidistant, behaves like mode 0. Otherwise, behaves like mode 1.1.235 → 1.24-1.235 → -1.24
5ROUND_HALF_DOWNNearest neighbor; if equidistant, towards zero. If both neighbors are equidistant, behaves like mode 1. Otherwise, behaves like mode 0.1.235 → 1.23-1.235 → -1.23
6ROUND_HALF_EVENNearest neighbor; if equidistant, towards even digit (banker's rounding)1.235 → 1.241.245 → 1.24

Choose a rounding mode

Use caseRecommended modeReason
General-purpose rounding4 (ROUND_HALF_UP)Standard "round half up" behavior that most developers expect.
Financial calculations6 (ROUND_HALF_EVEN)Banker's rounding minimizes cumulative rounding bias.
Always round up (absolute value)0 (ROUND_UP)Rounds away from zero regardless of sign.
Always truncate1 (ROUND_DOWN)Discards extra digits without rounding.
Sign-dependent rounding2 (ROUND_CEILING) or 3 (ROUND_FLOOR)Ceiling rounds towards positive infinity; floor rounds towards negative infinity.