Arithmetic Operators

Arithmetic operators in DataLogic-rs perform mathematical calculations and return numeric results.

+
-
*
/
%
min
max

+ (Addition)

Adds multiple values together. Only works with values that can be coerced to numbers. For string concatenation, use the cat operator instead.

Syntax

{ "+": [value1, value2, ...] }

Parameters

Parameter Description
value1, value2, ... Numeric values to add together

Example: Basic Addition

Rule:

Data:

Result:

Example: Adding Numbers and Variables

Rule:

Data:

Result:

- (Subtraction)

Subtracts values from the first value. If only one value is provided, it negates that value.

Syntax

{ "-": [value1, value2, ...] }

Parameters

Parameter Description
value1 Value to subtract from
value2, ... Values to subtract

Example

Rule:

Data:

Result:

Example: Negation

Rule:

Data:

Result:

* (Multiplication)

Multiplies values together.

Syntax

{ "*": [value1, value2, ...] }

Parameters

Parameter Description
value1, value2, ... Values to multiply together

Example

Rule:

Data:

Result:

/ (Division)

Divides the first value by all subsequent values.

Syntax

{ "/": [value1, value2, ...] }

Parameters

Parameter Description
value1 Dividend
value2, ... Divisors

Example

Rule:

Data:

Result:

% (Modulo)

Returns the remainder after dividing the first value by the second value.

Syntax

{ "%": [value1, value2] }

Parameters

Parameter Description
value1 Dividend
value2 Divisor

Example

Rule:

Data:

Result:

min

Returns the smallest value from a list of values.

Syntax

{ "min": [value1, value2, ...] }

Parameters

Parameter Description
value1, value2, ... Values to compare

Example

Rule:

Data:

Result:

max

Returns the largest value from a list of values.

Syntax

{ "max": [value1, value2, ...] }

Parameters

Parameter Description
value1, value2, ... Values to compare

Example

Rule:

Data:

Result: