Next: , Previous: ABORT, Up: Intrinsic Procedures


8.3 ABS — Absolute value

Description:
ABS(X) computes the absolute value of X.
Option:
f95, gnu
Class:
elemental function
Syntax:
X = ABS(X)
Arguments:

X The type of the argument shall be an INTEGER(*), REAL(*), or COMPLEX(*).

Return value:
The return value is of the same type and kind as the argument except the return value is REAL(*) for a COMPLEX(*) argument.
Example:
          program test_abs
            integer :: i = -1
            real :: x = -1.e0
            complex :: z = (-1.e0,0.e0)
            i = abs(i)
            x = abs(x)
            x = abs(z)
          end program test_abs
     

Specific names:

Name Argument Return type Option
CABS(Z) COMPLEX(4) Z REAL(4) f95, gnu
DABS(X) REAL(8) X REAL(8) f95, gnu
IABS(I) INTEGER(4) I INTEGER(4) f95, gnu
ZABS(Z) COMPLEX(8) Z COMPLEX(8) gnu
CDABS(Z) COMPLEX(8) Z COMPLEX(8) gnu