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 real
b
- Shall be of the same type and kind as a
The 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