DADiSP Worksheet Functions > Function Categories > Data Type Conversion > CASTCOMPLEX
Explicitly casts the input to a complex scalar.
CASTCOMPLEX(val)
val |
- |
A scalar, series or table. |
A complex number. If the imaginary part of the complex value is zero, only the real part is returned.
W1: gline(10,1,.5,.2) + i*gline(10,1,.5,8)
castcomplex(W1)
returns the value 0.2 + 8i.
iscomplex(castcomplex(1.0))
returns 1
CASTCOMPLEX is helpful when writing SPL functions that require an explicit complex input and the type of the variable passed into the function may not be complex.
If the input to CASTCOMPLEX is a series, it will only operate on the first point of the series.
If the input to CASTCOMPLEX is a table, it will only operate on the first point in the first column of the table.