SIGN intrinsic function

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


<Syntax>

SIGN ( A, B )

A : Integer or Real;
B : Same type and kind as A, conformable with A; Fortran 2018 permits B to have a different kind;

Result : Same type and kind as A.

<Semantics>

The result has the magnitude of A with the sign of B.

Prior to Fortran 95, if B was zero it was treated as being positive, even when it was an IEEE negative zero. From Fortran 95 onwards, the treatment of IEEE negative zero depends on the compiler; the NAG Fortran compiler treats IEEE negative zero as negative, unless the -f90_sign option was used at compilation time.

Like many intrinsic functions, this is elemental; if either (or both) of A and B is an array, the result will be an array with that shape, with the value being computed elementwise.

<Related>