Subtraction Operator (-) (FPScript)

23.08.2021

Subtracts two expressions from each other.

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, subtraction 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 subtracted, only their Y components are examined. 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 subtraction takes place 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.

Complex subtraction is defined as (a, b) - (c, d) = (a - c, b - d).

If you subtract time span values from calendar time values, the result is a calendar time value. If you subtract time span values from time span values, the result is a time span value. The same is true if you subtract calendar time values. You can also subtract a numeric value from a calendar time value or a time span value, which is then interpreted in seconds. The same is true if you subtract a time span value from a numeric value. For complex values, the absolute value is formed before subtraction in this case. Calendar times can, however, not be subtracted from a numeric value.

If one argument is numeric and the other is a string, the string is changed to the numeric 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 to the unit of Expression1 before being subtracted. 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), a reduction is calculated:

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

For the unit ppm, the calculation is accordingly performed with 1,000,000 ppm instead of with 100 %.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

Signal - Mean(Signal)

Removes the offset of a signal.

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

Shifts a signal to the left in the X direction.

(1., 2.) - 1.

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

"1.23" - 1n

Returns the 32-bit integer 0, since the string is changed to 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 10:30:00'.

'1/1/2000' - '1/1/2000 12:00:00'

Returns the time span value '-12:00:00'.

'12:00:00' - 120.5

Returns the time span value '11:57:59.5'.

3 m - 50 mm

Returns 2.95 m.

- 50 mm

Returns -47 mm.

3 m - 50

Returns -47 m.

200 m - 10 %

Returns 200 m - 200 m * (10/100) = 180 m.

 

See Also

Negation Operator (-)

Share article or send as email:

You might be interested in these articles