Numeric operation¤
Description¤
The Numeric operation plugin applies one of the four basic arithmetic operators to the sequence of input values and returns the numeric result as a string.
For configuring it, we provide an operator parameter that determines whether the input values should be added, subtracted, multiplied, or divided. Only the four operators +, -, *, and / are accepted. If any other operator is configured, the plugin fails at configuration time.
For calling it, we provide one or more input sequences. All values from all inputs are treated as operands of one single operation: the plugin collects them, parses them as numbers, and reduces the resulting operand sequence by repeatedly applying the configured operator. The computations are done with double-precision floating-point numbers, which is why inputs like 1 are treated as 1.0 and why results such as 1 + 1 are rendered as 2.0 rather than as an integer.
Applying the operator to multiple input values¤
The Numeric operation plugin does not apply the operator to one left value and one right value only. It applies the operator across the full sequence of parsed operands, independent of how those operands are distributed across the inputs, and returns exactly one value as the final reduction result.
Invalid values¤
Every input value must be a valid number. If any value is not a number, the plugin fails instead of skipping that value or treating it as 0. At least one numeric input value is required, because the operator is applied by reducing the operand sequence into a single result.
Division¤
Division is configured with the / operator. The symbol ÷ is not supported. Division by 0 does not fail and yields Infinity.
Examples¤
Notation: List of values are represented via square brackets. Example: [first, second] represents a list of two values “first” and “second”.
Example 1:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1][1]
-
Returns:
[2.0]
Example 2:
-
Parameters
- operator:
-
- operator:
-
Input values:
[1][1]
-
Returns:
[0.0]
Example 3:
-
Parameters
- operator:
*
- operator:
-
Input values:
[5][6]
-
Returns:
[30.0]
Example 4:
-
Parameters
- operator:
/
- operator:
-
Input values:
[5][2]
-
Returns:
[2.5]
Example 5:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1][no number]
-
Returns:
[]
Example 6:
-
Parameters
- operator:
*
- operator:
-
Input values:
[1][]
-
Returns:
[1.0]
Example 7:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1, 1][1]
-
Returns:
[3.0]
Example 8:
-
Parameters
- operator:
/
- operator:
-
Input values:
[1][0]
-
Returns:
[Infinity]
Parameter¤
Operator¤
The operator to be applied to all values. One of +, -, *, /
- ID:
operator - Datatype:
string - Default Value:
None
Advanced Parameter¤
None
Related Plugins¤
- aggregateNumbers — The Numeric operation plugin reduces all input numbers into one result using one arithmetic operator and fails when any value is not a number. The Aggregate numbers plugin also reduces to one result, but it ignores non-numeric values and shifts the operator set toward aggregation semantics such as minimum, maximum, and average.
- extractPhysicalQuantity — The Extract physical quantity plugin converts number-and-unit text into base-unit numeric values as plain numeric output. The Numeric operation plugin combines those numeric values using one arithmetic operator across the operand sequence.
- numReduce — Numeric reduce strips non-numeric characters from each value. Numeric operation then applies an arithmetic operator across the resulting values, since it throws on any input that is not a number.