Addition Operator (+) (FPScript)

23.08.2021

Adds two expressions.

Syntax

Expression1 + Expression2

The syntax of the + operator consists of the following elements:

Element

Description

Expression1

Any expression. All data types except Boolean values are permitted.

Expression2

Same as Expression1.

Remarks

The operator can process scalar values or entire data series and data matrices. If at least one argument is a data series or a data matrix, the addition takes place on a per-element basis and the result is once again a data series or a data matrix. If at least one of the two arguments is a data matrix, then both arguments must have the same number of rows. For a different number of columns in data matrices or for a different number of rows in data series, extra columns or values are removed.

If signals, signal series or space curves are added, only their Y components are taken into consideration. The result then preferably contains the X component and possibly the Z component of Expression1. Otherwise, it contains those of Expression2. If one of the expressions returns a list, then the operation is executed for each item in the list and the result is also a list.

The operator can be applied to all real and complex data types as well as to calendar times, time spans and strings. For complex arguments, complex addition is carried out and the result is also complex. The result is always of the same data type as the expressions. If the expressions have different data types, then these are adapted to each other in such a way that there is no loss of resolution in the result, i.e. lower resolutions are converted into higher resolutions, integers are converted into floating point values and real numbers converted into complex numbers.

The complex addition is defined as (a, b) + (c, d) = (a + c, b + d).

You can add time span values with calendar time values and with time span values. Both arguments, however, cannot be calendar time values. You can also add a numerical value to a calendar time value or a time span value, which is then interpreted in seconds. For complex values, the absolute value is formed and this is then added.

If one argument is numerical and the other is a string, the string is changed to numerical type before the operation. Both arguments cannot be strings.

If Expression1 and Expression2 is a quantity, then they have to have the same SI dimension and the unit of Expression2 is transformed before being added to the unit of Expression1. If only one operand is a quantity, then the same unit is used for the other operand. When Percentage Calculation is enabled and the right-hand operand is present in the unit % or ppm (parts per million), an addition is calculated:

Expression1 + Expression2[%] = Expression1 + Expression1 * (Expression2 / 100 %)

Accordingly, with the unit ppm, the calculation is made using 1,000,000 ppm instead of 100 %.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

Signal + 1.5

Add an offset to a signal.

2000000000n + 2000000000n

Returns the 32-bit integer -294967296, since there is an overflow.

Signal(Signal.y, Signal.x + 10)

Shifts a signal to the right in the X direction.

(1., 2.) + 1.

Returns the complex 64-bit floating point value (2., 2.).

"1,23" + 2n

Returns the 32-bit integer 3, since the string is changed into the data type of the numeric result. Note that the country-specific decimal symbol set in Windows must be used in the string.

'1.1.2000 12:00:00' + '1:30:00'

Returns the calendar time value '1.1.2000 13:30:00'.

'12:00:00' + 120.5

Returns the time span value '12:02:00.5'.

3 m + 50 mm

Returns 3.05 m.

+ 50 mm

Returns 53 mm.

3 m + 50

Returns 53 m.

200 m + 10 %

Returns 200 m + 200 m * (10/100) = 220 m.

 

See Also

Concatenation Operator (:) for appending two strings to each other.

Share article or send as email:

You might be interested in these articles