ieee_copy_sign

Date:

10-12-2011

NAME

IEEE_COPY_SIGN - Returns x with the sign of y

SYNOPSIS

IEEE_COPY_SIGN ([X=]x [,Y=]y)

STANDARDS

Fortran

IEEE Standard for Binary Floating-point Arithmetic

DESCRIPTION

The IEEE_COPY_SIGN intrinsic function returns x with the sign of y. For example, ABS(x) = IEEE_COPY_SIGN(x, 1.0) even if x is a NaN or an infinity.

The Fortran standard SIGN() intrinsic function produces the same result as IEEE_COPY_SIGN on systems that support IEEE floating-point arithmetic.

This function accepts the following arguments:

x

Must be of type real.

y

Must be of type real.

IEEE_COPY_SIGN is an elemental function. The name of this intrinsic cannot be passed as an argument.

NOTES

The IEEE intrinsic procedures use the named constants contained in a system module, so you must include the following statement in your program:

USE, INTRINSIC :: IEEE_ARITHMETIC

Use IEEE_SUPPORT_DATATYPE(x) and IEEE_SUPPORT_DATATYPE(y) to determine if the data type and type parameters are supported before referencing IEEE_COPY_SIGN.

RETURN VALUES

The return value is of the same type and type parameter as x.

The result has the same value as x but with the sign of y.

EXAMPLES

Example 1:

The following PRINT statement is executed on a system that supports the IEEE standard for floating-point arithmetic:

USE, INTRINSIC :: IEEE_ARITHMETIC
PRINT *, IEEE_COPY_SIGN(5.0,-0.0)

The output of the preceding PRINT statement is -5.0.

SEE ALSO

sign(3i)