]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/abs.rst
ecc7495ba39dcc53473113200f20a5be1079dbcc
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / abs.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _abs:
7
8 .. index:: ABS
9
10 .. index:: CABS
11
12 .. index:: DABS
13
14 .. index:: IABS
15
16 .. index:: ZABS
17
18 .. index:: CDABS
19
20 .. index:: BABS
21
22 .. index:: IIABS
23
24 .. index:: JIABS
25
26 .. index:: KIABS
27
28 .. index:: absolute value
29
30 ABS --- Absolute value
31 **********************
32
33 .. function:: ABS(A)
34
35 ``ABS(A)`` computes the absolute value of ``A``.
36
37 :param A:
38 The type of the argument shall be an ``INTEGER``,
39 ``REAL``, or ``COMPLEX``.
40
41 :return:
42 The return value is of the same type and
43 kind as the argument except the return value is ``REAL`` for a
44 ``COMPLEX`` argument.
45
46 Standard:
47 Fortran 77 and later, has overloads that are GNU extensions
48
49 Class:
50 Elemental function
51
52 Syntax:
53 .. code-block:: fortran
54
55 RESULT = ABS(A)
56
57 Example:
58 .. code-block:: fortran
59
60 program test_abs
61 integer :: i = -1
62 real :: x = -1.e0
63 complex :: z = (-1.e0,0.e0)
64 i = abs(i)
65 x = abs(x)
66 x = abs(z)
67 end program test_abs
68
69 Specific names:
70 .. list-table::
71 :header-rows: 1
72
73 * - Name
74 - Argument
75 - Return type
76 - Standard
77
78 * - ``ABS(A)``
79 - ``REAL(4) A``
80 - ``REAL(4)``
81 - Fortran 77 and later
82 * - ``CABS(A)``
83 - ``COMPLEX(4) A``
84 - ``REAL(4)``
85 - Fortran 77 and later
86 * - ``DABS(A)``
87 - ``REAL(8) A``
88 - ``REAL(8)``
89 - Fortran 77 and later
90 * - ``IABS(A)``
91 - ``INTEGER(4) A``
92 - ``INTEGER(4)``
93 - Fortran 77 and later
94 * - ``BABS(A)``
95 - ``INTEGER(1) A``
96 - ``INTEGER(1)``
97 - GNU extension
98 * - ``IIABS(A)``
99 - ``INTEGER(2) A``
100 - ``INTEGER(2)``
101 - GNU extension
102 * - ``JIABS(A)``
103 - ``INTEGER(4) A``
104 - ``INTEGER(4)``
105 - GNU extension
106 * - ``KIABS(A)``
107 - ``INTEGER(8) A``
108 - ``INTEGER(8)``
109 - GNU extension
110 * - ``ZABS(A)``
111 - ``COMPLEX(8) A``
112 - ``REAL(8)``
113 - GNU extension
114 * - ``CDABS(A)``
115 - ``COMPLEX(8) A``
116 - ``REAL(8)``
117 - GNU extension