The SIGN function transfers the sign of a REAL or INTEGER argument.

## Syntax

SIGN (a,b)

*a* is an INTENT(IN) scalar or array of type INTEGER or REAL.

*b* is an INTENT(IN) scalar or array of type INTEGER or REAL.

If both *a* and *b* are arrays, they must have the same shape.

The result is of the same type and kind as *a*.

Its value is |*a*|, if *b* is greater than or equal to zero; and -|*a*| if *b* is less than zero. The compiler does not distinguish between positive and negative zero.

If either or both arguments are arrays, the result is an array with the same shape. Each element of the result is as though the scalar SIGN operation were performed on each respective element of the argument arrays.

## Example

real :: r=1. integer :: ia(2)=(/2,-3/) write(*,*) sign(r,-1) ! writes -1. write(*,*) sign(r,ia) ! writes 1., -1. write(*,*) sign(ia,-1) ! writes -2 -3