This article demonstrates the behavior of integer or float data when arithmetic operators are used in the formula mode.
What you'll need:
Skill level: Intermediate
Time required: 3 minutes
- Skills of arithmetic operators
Quickwork supports a variety of arithmetic formulas. Formulas are whitelisted Ruby methods, and therefore not all Ruby methods are supported. Syntax and functionality for these formulas are generally unchanged. Take note that most formulas will return an error and stop the job if it tries to operate on nulls (expressed as nil in Ruby).
In the cases of arithmetic operations, the values in integer types or decimal (float) types are important. Formulas will always stick to the types given as input, and the returned result will be of the most precise type.
- If integer values are provided, an integer value will be returned.
- If float values are provided, a float value will be returned.
- If both float and integer values are provided, a float value will be returned as that is more precise.
The add (+) operator
This operator allows the addition of operands present on both sides:
|4 + 7||11||Integer|
The subtract (-) operator
This operator subtracts the right-hand operand from the left-hand operand:
|4 - 7||-3||Integer|
The multiply (*) operator
This operator multiplies the operands on either side:
The divide (/) operator
Divides left-hand operand by right-hand operand:
You can refer to the complete Ruby documentation for integers here as well as the Ruby documentation for float (decimals) here.
Please sign in to leave a comment.