The Bridge supports the following basic arithmetic operations: multiplication, division, subtraction, and addition.

It is allowed to put expressions into parentheses, e.g. 3*(4+2) instead of 3*4 + 3*2.
Arithmetic expressions may be defined in the scripts section of action nodes. The first line in the example below creates the output object result . This is required before the attributes can be set. The following lines show examples of referencing the input values in mathematical operations.

Figure: Arithmetic Operations

If you provide the value 1 for numbers.integer2, the value of result.Integer2 will be 2 (2.66 will be cut after the decimal point) because the result value is of type integer whereas the value of result.float1 will be 2.66.

The variables and literals involved in an arithmetic expression must all be of the same type. This means you may not mix integers and floats. The expression set result.float1 = 1 +5/3 would cause a compilation error because 1, 5, and 3 are of type integer. If you want the result to be a float, you must specify the integers in float notation, thus appending .0.

DateTime Arithmetics

Besides doing arithmetic with numbers it is also possible to do DateTime arithmetic. It is allowed to add/subtract durations to/from a given DateTime object. The UML example above shows how to add one month to a given DateTime object:

set resultDateTime = dateTime + convertDurationToDateTime("P1M");

This is calculated e.g. as follows:

  1. 31.01.2017 + 1 month = 31.02.2017
  2. The resulting date 31.02.2017 is normalized to 03.03.2017.

In fact, these objects are represented as DateTime types but they are actually durations. For the exact lexical definition of duration, refer to convertDurationToDateTime.

You can also use dedicated DateTime operations for these arithmetics (see DateTime Operations), e.g. add subtract:

create duration; 
set duration.months = 1; 

set resultDateTime = dateTime.add(duration);
set resultDateTime = dateTime.subtract(duration);

Be careful with the following:

  • It is not allowed to add up two dates.
  • To find out the duration between two dates better use the difference() operation instead of subtracting them.