Fortran Wiki abs

Description

abs(a) computes the absolute value of a.

Standard

FORTRAN 77 and later

Class

Elemental function

Syntax

result = abs(a)

Arguments

• a - 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

category: intrinsics