[UP]


Manual Reference Pages  - sign (3)

NAME

sign(3f) - [FORTRAN:INTRINSIC:NUMERIC] Sign copying function

SYNTAX

result = sign(a, b)

DESCRIPTION

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

ARGUMENTS

A Shall be of type INTEGER or REAL
B Shall 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 >= 0 then the result is abs(a), else it is -abs(a).

EXAMPLE

Sample program:

    program demo_sign
    implicit none
      print *, sign( -12,  1 )
      print *, sign( -12,  0 )
      print *, sign( -12, -1 )

print *, sign( -12.0, 1.0 ) print *, sign( -12.0, 0.0 ) print *, sign( -12.0, -1.0 ) end program demo_sign

Results:

             12
             12
-12
12.0000000
12.0000000
 
-12.0000000
 

STANDARD

[[FORTRAN 77]] and later

CLASS

[[Elemental procedure|Elemental function]]


sign (3) March 11, 2021
Generated by manServer 1.08 from 5d022803-ecf5-4be3-b153-902da3a4740f using man macros.