Division Remainder Operator (Mod) (FPScript)

23.08.2021

Determines the remainder of a division.

Syntax

Dividend Mod Divisor

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

Element

Description

Dividend

Any expression. All real data types and strings are permitted.

Divisor

Same as Dividend. However, it cannot be 0.

Remarks

The remainder of the division is the value that must be subtracted from Dividend for the division to be integral. The Divisor does not have to be a whole number.

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, division 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 divided, only their Y components are examined. The result then preferably contains the X component and possibly the Z component of Dividend. Otherwise, it contains those of Divisor. 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.

You can apply the operator to all real data types as well as to time spans and strings. 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 so that there is no loss of resolution in the result, i.e. lower resolutions are converted into higher resolutions and integers are converted into floating point values.

You can divide time span values by numeric values or time span values. Both operands are then interpreted as seconds and the result is a time span value corresponding to the division remainder.

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.

Dividing by zero with floating point data types results in a void value. When integral data types are used, then an error is output.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

5. Mod 1.5

Returns the 64-bit floating point value 0.5, since 5 = 3 * 1.5 + 0.5, meaning that 1.5 passes three times into 5 with 0.5 as the remainder.

"5,5" Mod 2n

Returns the 32-bit integer 1, 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.

'12:34:56.78' Mod 60

Returns the time span value '00:00:36.78', i.e. the fraction of a second.

'12:34:56.78' Mod 3600 - '12:34:56.78' Mod 60

Returns the time span value '00:34:00', i.e. the fraction of a minute.

{ 3., 2.} Mod {2., 0.}

Returns the data series with 64-bit floating point values { 1., ? }.

 

See Also

Division Operator (/)

Share article or send as email:

You might be interested in these articles