LF Fortran 95

ABS Function

Description

The ABS function returns the absolute value of a numeric argument.

Syntax

Syntax

ABS (a)

Arguments

a is an INTENT(IN) scalar or array of type REAL, INTEGER, or COMPLEX.

Result

If a is INTEGER or REAL, the result is the same type and kind as a and has the value |a|.

If a is COMPLEX with value (x,y), the result is a REAL value with the same kind as a, and

is a representation of √(x²+y²).

Example

       real :: y=-4.5
       complex :: z=(1.,-1.)
       write(*,*) abs(y)  ! writes 4.5000000
       write(*,*) abs(z)  ! writes 1.4142135