ABS Function

Returns the absolute value of x.

enabled.

Usage

    result = ABS(x)

Input Parameters

x—The value that is evaluated. May be of any dimension.

Returned Value

result—The absolute value of x.

Keywords

None.

Discussion

ABS is defined by:

    f(x) = |x|

If x is an array, the result has the same dimension. Each element of the returned array contains the absolute value of the corresponding element in the input array.

When x is complex, the result is the magnitude of the complex number:

When x has a data type of complex, the result is double-precision floating-point. All other data types produce a result with the same data type as x.

Example

x = [-1, 2, 3, -4, 5]
PRINT, ABS(x)
; PV-WAVE prints: 1    2    3    4    5
x = COMPLEX(4, 3) 
PRINT, ABS(x)
; PV-WAVE prints: 5.0000000