Arithmetic expressions - Cloud

Talend Data Shaping Language Reference Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Data Shaping Language
Content
Design and Development

You can use the following operators to perform arithmetic operations in your expressions:
  • + for a sum
  • - for a subtraction
  • * for a multiplication
  • / for a division
  • % for a modulo
You can use different data types in the same operation. When using different numeric types, the following rules apply:
  • If the expression contains at least one decimal, all other types are converted to decimal.
  • If the expression contains at least one double and no decimal, then integers, longs and floats are converted to double.
  • If the expression contains at least one float and no double or decimal, then integers and longs are converted to float.
  • If the expression contains at least one long and no float, double or decimal, then integers are converted to long.

Strings and bytes can be converted to numeric types in expressions that contain at least one numeric type. For example, in "1" + 2, "1" is converted to an integer to perform the operation. However, "1" + "2" is not valid.

The following examples are valid arithmetic expressions:
1 + 12.5
16 % 5
3 * 5 + 7.12f
"3.1415" + 2
3.5 - "1.5f"
1 + 0x01
0.1f + 0xFF