Next: , Previous: SET_EXPONENT, Up: Intrinsic Procedures


8.94 SIGN — Sign copying function

Description:
SIGN(A,B) returns the value of A with the sign of B.
Option:
f95, gnu
Class:
elemental function
Syntax:
X = SIGN(A,B)
Arguments:

A shall be a scalar of type INTEGER or REAL
B shall be a scalar of the same type and kind as A

Return value:
The kind of the return value is that of A and B. If B\ge 0 then the result is ABS(A), else it is -ABS(A).
Example:
          program test_sign
            print *, sign(-12,1)
            print *, sign(-12,0)
            print *, sign(-12,-1)
          
            print *, sign(-12.,1.)
            print *, sign(-12.,0.)
            print *, sign(-12.,-1.)
          end program test_sign
     

Specific names:

Name Arguments Return type Option
ISIGN(A,P) INTEGER(4) INTEGER(4) f95, gnu
DSIGN(A,P) REAL(8) REAL(8) f95, gnu