9.3.142 SIGN (A, B)

Description:  Returns the absolute value of A times the sign of B.  
Class:  Elemental function; Generic 
Arguments:  A Must be of type integer or real. 
  B Must have the same type and kind parameters as A. 
Results:  The result type is the same as A. The value of the result is |A| if B >= zero and -|A| if B < zero.

If B is of type real and zero, the value of the result is |A|. However, if the processor can distinguish between positive and negative real zero and the appropriate compiler option is specified, 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|.
Specific Name  Argument Type  Result Type 
  INTEGER(1)  INTEGER(1) 
IISIGN  INTEGER(2)  INTEGER(2) 
ISIGN 1  INTEGER(4)  INTEGER(4) 
KISIGN  INTEGER(8)  INTEGER(8) 
SIGN  REAL(4)  REAL(4) 
DSIGN  REAL(8)  REAL(8) 
QSIGN  REAL(16)  REAL(16) 
1 Or JISIGN. For compatibility with older versions of Fortran, ISIGN can also be specified as a generic function.

Examples

SIGN (4.0, -6.0) has the value -4.0.

SIGN (-5.0, 2.0) has the value 5.0.


Previous Page Next Page Table of Contents