Next: , Previous: , Up: Intrinsic Procedures   [Contents][Index]


9.238 SIGN — Sign copying function

Description:

SIGN(A,B) returns the value of A with the sign of B.

Standard:

Fortran 77 and later

Class:

Elemental function

Syntax:

RESULT = SIGN(A, B)

Arguments:
AShall be of type INTEGER or REAL
BShall be 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:
NameArgumentsReturn typeStandard
SIGN(A,B)REAL(4) A, BREAL(4)f77, gnu
ISIGN(A,B)INTEGER(4) A, BINTEGER(4)f77, gnu
DSIGN(A,B)REAL(8) A, BREAL(8)f77, gnu