SUBS
Synopsis
SUBS(dynarray1,dynarray2)
Arguments
dynarray1 | The minuend. An expression that resolves to a dynamic array of numeric values. If a dynamic array element contains a non-numeric value, SUBS treats this value as 0 (zero). |
dynarray2 | The subtrahend. An expression that resolves to a dynamic array of numeric values. If a dynamic array element contains a non-numeric value, SUBS treats this value as 0 (zero). |
Description
The SUBS function subtracts the value of each element in dynarray2 from the corresponding element in dynarray1. It then returns a dynamic array containing the results of these subtractions. If an element value is missing, or is the null string or a non-numeric value, SUBS parses its value as 0 (zero).
If the two dynamic arrays have different numbers of elements, the returned dynamic array has the number of elements of the longer dynamic array. By default, the shorter dynamic array is padded with 0 value elements for the purpose of the arithmetic operation. You can also use the REUSE function to define behavior when specifying two dynamic arrays with different numbers of elements.
You can use the ADDS (addition), MULS (multiplication), DIVS or DIVSZ (division), MODS (modulo division), and PWRS (exponentiation) functions to perform other arithmetic operations on the corresponding elements of two dynamic arrays.
Examples
The following example uses the SUBS function to subtract the elements of two dynamic arrays:
a=11:@VM:22:@VM:33:@VM:44
b=10:@VM:9:@VM:8:@VM:7
PRINT SUBS(a,b)
! returns 1ý13ý25ý37
The following example subtracts elements of dynamic arrays of differing lengths:
a=11:@VM:22:@VM:33:@VM:44
b=2:@VM:2:@VM:2:@VM:2:@VM:2:@VM:2
PRINT SUBS(a,b)
! returns 9ý20ý31ý42ý-2ý-2