Operators (Arithmetic)

Arithmetic

Numeric Operations: Add, Subtract, Multiply, Divide

Operators

operatordescriptionexample
+Addition1 + 1
-Subtraction2 - 3
*Multiplication3 * 3
/Division8 / 4

Usage

result_field_name: field_name + const - spec_field_name.eval * const

Notes:

  • field_name represents a previously declared constant field of type number.
  • const represents a constant such as the number 2.5.
  • Reference spec_field_name.eval returns a result of type number.
  • Order matters when referencing fields. An arithmetic operation must come after all the specifications it references.

References

Arithmetic operations require a working knowledge of references. For more on how references work see the References Section.

  • Arithmetic operations only work with numeric types.

Examples

Number Step with Arithmetic Operations

int_step: #SpecNumberStep & { value: 2 step: 2 } add_one: int_step.eval + 1 multiply_two: add_one.eval * 2 add_all: int_step.eval + add_one + multiply_two

CSV Example Output

int_stepadd_onemultiply_twoadd_all
23611
451019
671427
891835

JSON Example Output

[ { "int_step": 2, "add_one": 3, "multiply_two": 6, "add_all": 11 }, { "int_step": 4, "add_one": 5, "multiply_two": 10, "add_all": 19 }, { "int_step": 6, "add_one": 7, "multiply_two": 14, "add_all": 27 }, { "int_step": 11, "add_one": 19, "multiply_two": 27, "add_all": 35 } ]