Visible to Intel only — GUID: GUID-6CCEF958-E6FB-453D-A291-2F103F74BD99
Visible to Intel only — GUID: GUID-6CCEF958-E6FB-453D-A291-2F103F74BD99
SIGN
Elemental Intrinsic Function (Generic): Returns the absolute value of the first argument times the sign of the second argument.
result = SIGN (a, b)
a |
(Input) Must be of type integer or real. |
b |
(Input) Must have the same type as a. |
Results
The result type and kind are the same as a. The value of the result is as follows:
| a | if b > zero and -| a | if b < zero.
| a | if b is of type integer and is zero.
If b is of type real and zero and compiler option assume minus0 is not specified, the value of the result is | a |.
If b is of type real and zero and compiler option assume minus0 is specified, the processor can distinguish between positive and negative real zero and the following occurs:
If b is positive real zero, the value of the result is | a |.
If b is negative real zero, the value of the result is -| a |.
The specific named versions of the function require that the arguments have the same kind parameters. The generic form of the function permits the kind types of the arguments to differ.
Specific Name |
Argument Type |
Result Type |
---|---|---|
BSIGN |
INTEGER(1) |
INTEGER(1) |
IISIGN1 |
INTEGER(2) |
INTEGER(2) |
ISIGN 2 |
INTEGER(4) |
INTEGER(4) |
KISIGN |
INTEGER(8) |
INTEGER(8) |
SIGN 3 |
REAL(4) |
REAL(4) |
DSIGN 3,4 |
REAL(8) |
REAL(8) |
QSIGN |
REAL(16) |
REAL(16) |
1 Or HSIGN. 2 Or JISIGN. For compatibility with older versions of Fortran, ISIGN is treated as a generic function. 3 The setting of compiler options specifying real size can affect SIGN and DSIGN . 4 The setting of compiler options specifying double size can affect DSIGN. |
Example
SIGN (4.0, -6.0) has the value -4.0.
SIGN (-5.0, 2.0) has the value 5.0.
The following shows another example:
c = SIGN (5.2, -3.1) ! returns -5.2
c = SIGN (-5.2, -3.1) ! returns -5.2
c = SIGN (-5.2, 3.1) ! returns 5.2