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:

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

See Also