sign(a,b) returns the value of a with the sign of b.
FORTRAN 77 and later
result = sign(a, b)
a - Shall be of type integer or realb - Shall be of the same type and kind as aThe kind of the return value is that of a and b. If then the result is abs(a), else it is -abs(a).
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