sign(3f) - [FORTRAN:INTRINSIC:NUMERIC] Sign copying function
result = sign(a, b)
sign(a,b) returns the value of A with the sign of 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 B >= 0 then the result is abs(a), else it is -abs(a).
Sample program:
program demo_sign implicit none print *, sign( -12, 1 ) print *, sign( -12, 0 ) print *, sign( -12, -1 )Results:print *, sign( -12.0, 1.0 ) print *, sign( -12.0, 0.0 ) print *, sign( -12.0, -1.0 ) end program demo_sign
12 12-12
12.0000000
12.0000000
-12.0000000
[[FORTRAN 77]] and later
[[Elemental procedure|Elemental function]]
sign (3) | March 11, 2021 |