]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/sign.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / sign.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 .. _sign:
7
8 .. index:: SIGN
9
10 .. index:: ISIGN
11
12 .. index:: DSIGN
13
14 .. index:: sign copying
15
16 SIGN --- Sign copying function
17 ******************************
18
19 .. function:: SIGN(A,B)
20
21 ``SIGN(A,B)`` returns the value of :samp:`{A}` with the sign of :samp:`{B}`.
22
23 :param A:
24 Shall be of type ``INTEGER`` or ``REAL``
25
26 :param B:
27 Shall be of the same type and kind as :samp:`{A}`.
28
29 :return:
30 The kind of the return value is that of :samp:`{A}` and :samp:`{B}`.
31 If B \ge 0 then the result is ``ABS(A)``, else
32 it is ``-ABS(A)``.
33
34 Standard:
35 Fortran 77 and later
36
37 Class:
38 Elemental function
39
40 Syntax:
41 .. code-block:: fortran
42
43 RESULT = SIGN(A, B)
44
45 Example:
46 .. code-block:: fortran
47
48 program test_sign
49 print *, sign(-12,1)
50 print *, sign(-12,0)
51 print *, sign(-12,-1)
52
53 print *, sign(-12.,1.)
54 print *, sign(-12.,0.)
55 print *, sign(-12.,-1.)
56 end program test_sign
57
58 Specific names:
59 .. list-table::
60 :header-rows: 1
61
62 * - Name
63 - Arguments
64 - Return type
65 - Standard
66
67 * - ``SIGN(A,B)``
68 - ``REAL(4) A, B``
69 - ``REAL(4)``
70 - Fortran 77 and later
71 * - ``ISIGN(A,B)``
72 - ``INTEGER(4) A, B``
73 - ``INTEGER(4)``
74 - Fortran 77 and later
75 * - ``DSIGN(A,B)``
76 - ``REAL(8) A, B``
77 - ``REAL(8)``
78 - Fortran 77 and later