XL Fortran for AIX 8.1

Language Reference


IEEE PROCEDURES

To use the following IEEE procedures, you must add a USE IEEE_ARITHMETIC, USE IEEE_EXCEPTIONS, or USE IEEE_FEATURES statement to your source file as required. For more information on the USE statement, see USE.

Rules for Using IEEE Procedures

XL Fortran supports all the named constants in the IEE_FEATURES module.

The IEEE_ARITHMETIC module behaves as if it contained a USE statement for IEEE_EXCEPTIONS. All values that are public in IEEE_EXCEPTIONS remain public in IEEE_ARITHMETIC.

When the IEEE_EXCEPTIONS or the IEEE_ARITHMETIC modules are accessible, IEEE_OVERFLOW and IEEE_DIVIDE_BY_ZERO are supported in the scoping unit for all kinds of real and complex data. To determine the other exceptions supported use the IEEE_SUPPORT_FLAG function. Use IEEE_SUPPORT_HALTING to determine if halting is supported. Support of other exceptions is influenced by the accessibility of the named constants IEEE_INEXACT_FLAG, IEEE_INVALID_FLAG, and IEEE_UNDERFLOW_FLAG of the IEEE_FEATURES module as follows:

If an exception flag signals on entry to a scoping unit that does not access IEEE_EXCEPTIONS or IEEE_ARITHMETIC, the compiler ensures that the exception flag is signaling on exit. If a flag is quiet on entry to such a scoping unit, it can be signaling on exit.

Further IEEE support is available through the IEEE_ARITHMETIC module. Support is influenced by the accessibility of named constants in the IEEE_FEATURES module:

If the IEEE_EXCEPTIONS or IEEE_ARITHMETIC modules are accessed, and IEEE_FEATURES is not, the supported subset of features is the same as if IEEE_FEATURES was accessed.

IEEE_CLASS(X)

An elemental IEEE class function. Returns the IEEE class of a floating-point value.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

The result is of type IEEE_CLASS_TYPE.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) function must return with a value of true. If you specify a data type of REAL(16), then IEEE_SUPPORT_DATATYPE will return false, though the appropriate class type will still be returned.

Examples

USE IEEE_ARITHMETIC 
TYPE(IEEE_CLASS_TYPE) :: C 
REAL :: X = -1.0 
IF (IEEE_SUPPORT_DATATYPE(X)) THEN   
  C = IEEE_CLASS(X)                ! C has class IEEE_NEGATIVE_NORMAL
ENDIF

IEEE_COPY_SIGN(X, Y)

An elemental IEEE copy sign function. Returns the value of X with the sign of Y.

Module

IEEE_ARITHMETIC

Syntax

Where X and Y are of type real, though they may be of different kinds.

Result Type

The result is of the same kind and type as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_DATATYPE(Y) must return with a value of true.

For supported IEEE special values, such as NaN and infinity, IEEE_COPY_SIGN returns the value of X with the sign of Y.

IEEE_COPY_SIGN ignores the -qxlf90=nosignedzero compiler option.

Note:
XL Fortran REAL(16) numbers have no signed zero.

Examples

Example 1:

USE IEEE_ARITHMETIC
REAL   :: X
DOUBLE PRECISION :: Y
X =  3.0
Y = -2.0
IF (IEEE_SUPPORT_DATATYPE(X) .AND. IEEE_SUPPORT_DATATYPE(Y)) THEN
  X = IEEE_COPY_SIGN(X,Y)               ! X has value -3.0
ENDIF
 

Example 2:

USE IEEE_ARITHMETIC
REAL :: X, Y
X =  5.0
Y =  1.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  X = IEEE_VALUE(X, IEEE_NEGATIVE_INF)  ! X has value -INF
  X = IEEE_COPY_SIGN(X,Y)               ! X has value +INF
ENDIF

IEEE_GET_FLAG(FLAG, FLAG_VALUE)

An elemental IEEE subroutine. Retrieves the status of the exception flag specified. Sets FLAG_VALUE to true if the flag is signaling, or false otherwise.

Module

IEEE_ARITHMETIC

Syntax

Where FLAG is an INTENT(IN) argument of type IEEE_FLAG_TYPE specifying the IEEE flag to obtain. FLAG_VALUE is an INTENT(OUT) default logical argument that contains the value of FLAG.

Examples

USE IEEE_EXCEPTIONS
LOGICAL :: FLAG_VALUE
CALL IEEE_GET_FLAG(IEEE_OVERFLOW,FLAG_VALUE)
IF (FLAG_VALUE) THEN
  PRINT *, "Overflow flag is signaling."
ELSE
  PRINT *, "Overflow flag is quiet."
ENDIF

IEEE_GET_HALTING_MODE(FLAG, HALTING)

An elemental IEEE subroutine. Retrieves the halting mode for an exception and sets HALTING to true if the exception specified by the flag will cause halting. If you use -qflttrap=imprecise, halting is not precise and may occur after the exception. By default, exceptions do not cause halting in XL Fortran.

Module

IEEE_ARITHMETIC

Syntax

Where FLAG is an INTENT(IN) argument of type IEEE_FLAG_TYPE specifying the IEEE flag. HALTING is an INTENT(OUT) default logical.

Examples

USE IEEE_EXCEPTIONS
LOGICAL HALTING
CALL IEEE_GET_HALTING_MODE(IEEE_OVERFLOW,HALTING)
IF (HALTING) THEN
  PRINT *, "The program will halt on an overflow exception."
ENDIF

IEEE_GET_ROUNDING_MODE (ROUND_VALUE)

An IEEE subroutine. Sets ROUND_VALUE to the current IEEE rounding mode.

Module

IEEE_ARITHMETIC

Syntax

Where ROUND_VALUE is an INTENT(OUT) scalar of type IEEE_ROUND_TYPE.

Examples

USE IEEE_ARITHMETIC
TYPE(IEEE_ROUND_TYPE) ROUND_VALUE
CALL IEEE_GET_ROUNDING_MODE(ROUND_VALUE) ! Store the rounding mode
IF (ROUND_VALUE == IEEE_OTHER) THEN
  PRINT *, "You are not using an IEEE rounding mode."
ENDIF

IEEE_GET_STATUS(STATUS_VALUE)

An IEEE subroutine. Retrieves the current IEEE floating-point status.

Module

IEEE_ARITHMETIC

Syntax

Where STATUS_VALUE is an INTENT(OUT) scalar of type IEEE_STATUS_TYPE.

Rules

You can only use STATUS_VALUE in an IEEE_SET_STATUS invocation.

Examples

USE IEEE_ARITHMETIC
TYPE(IEEE_STATUS_TYPE) STATUS_VALUE
...
CALL IEEE_GET_STATUS(STATUS_VALUE)   ! Get status of all exception flags
CALL IEEE_SET_FLAG(IEEE_ALL,.FALSE.) ! Set all exception flags to quiet
... ! calculation involving exception handling
CALL IEEE_SET_STATUS(STATUS_VALUE)   ! Restore the flags

IEEE_IS_FINITE(X)

An elemental IEEE function. Tests whether a value is finite. Returns true if IEEE_CLASS(X) has one of the following values:

It returns false otherwise.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

Examples

USE IEEE_ARITHMETIC
REAL :: X = 1.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  PRINT *, IEEE_IS_FINITE(X)    ! Prints true
ENDIF

IEEE_IS_NAN(X)

An elemental IEEE function. Tests whether a value is IEEE Not-a-Number. Returns true if IEEE_CLASS(X) has the value IEEE_SIGNALING_NAN or IEEE_QUIET_NAN. It returns false otherwise.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_NAN(X) must return with a value of true.

Examples

Example 1:

USE IEEE_ARITHMETIC
REAL :: X = -1.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  IF (IEEE_SUPPORT_SQRT(X)) THEN    ! IEEE-compliant SQRT function
    IF (IEEE_SUPPORT_NAN(X)) THEN
      PRINT *, IEEE_IS_NAN(SQRT(X)) ! Prints true
    ENDIF
  ENDIF
ENDIF
 

Example 2:

USE IEEE_ARITHMETIC
REAL :: X = -1.0
IF (IEEE_SUPPORT_STANDARD(X)) THEN
  PRINT *, IEEE_IS_NAN(SQRT(X))     ! Prints true
ENDIF

IEEE_IS_NEGATIVE(X)

An elemental IEEE function. Tests whether a value is negative. Returns true if IEEE_CLASS(X) has one of the following values:

It returns false otherwise.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(1.0)) THEN
  PRINT *, IEEE_IS_NEGATIVE(1.0)    ! Prints false
ENDIF

IEEE_IS_NORMAL(X)

An elemental IEEE function. Tests whether a value is normal. Returns true if IEEE_CLASS(X) has one of the following values:

It returns false otherwise.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

Examples

USE IEEE_ARITHMETIC
REAL :: X = -1.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  IF (IEEE_SUPPORT_SQRT(X)) THEN     ! IEEE-compliant SQRT function
    PRINT *, IEEE_IS_NORMAL(SQRT(X)) ! Prints false
  ENDIF
ENDIF

IEEE_LOGB(X)

An elemental IEEE function. Returns unbiased exponent in the IEEE floating-point format. If the value of X is neither zero, infinity, or NaN, the result has the value of the unbiased exponent of X, equal to EXPONENT(X)-1.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is the same type and kind as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X is zero, the result is negative infinity.

If X is infinite, the result is positive infinity.

If X is NaN, the result is NaN.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(1.1)) THEN
  PRINT *, IEEE_LOGB(1.1)  ! Prints 0.0
ENDIF

IEEE_NEXT_AFTER(X, Y)

An elemental IEEE function. Returns the next machine-representable neighbor of X in the direction towards Y.

Module

IEEE_ARITHMETIC

Syntax

Where X and Y are of type real.

Result Type

Where the result is the same type and kind as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_DATATYPE(Y) must return with a value of true.

If X and Y are equal the function returns X without signaling an exception. If X and Y are not equal, the function returns the next machine-representable neighbor of X in the direction towards Y.

The neighbors of zero, of either sign, are both nonzero.

IEEE_OVERFLOW and IEEE_INEXACT are signaled when X is finite but IEEE_NEXT_AFTER(X, Y) is infinite.

IEEE_UNDERFLOW and IEEE_INEXACT are signaled when IEEE_NEXT_AFTER(X, Y) is denormalized or zero.

If X or Y is a quiet NaN, the result is one of the input NaN values.

Examples

Example 1:

USE IEEE_ARITHMETIC
REAL :: X = 1.0, Y = 2.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  PRINT *, (IEEE_NEXT_AFTER(X,Y) == X + EPSILON(X))  ! Prints true
ENDIF
 

Example 2:

USE IEEE_ARITHMETIC
REAL(4) :: X = 0.0, Y = 1.0
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  PRINT *, (IEEE_NEXT_AFTER(X,Y) == 2.0**(-149))  ! Prints true
ENDIF

IEEE_REM(X, Y)

An elemental IEEE remainder function. The result value, regardless of the rounding mode, is exactly X-Y*N, where N is the integer nearest to the exact value X/Y; whenever |N - X/Y| = 1/2, N is even.

Module

IEEE_ARITHMETIC

Syntax

Where X and Y are of type real.

Result Type

Where the result is of type real with the same kind as the argument with greater precision.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_DATATYPE(Y) must return with a value of true.

If the result value is zero, the sign is the same as X.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(4.0)) THEN
  PRINT *, IEEE_REM(4.0,3.0)  ! Prints  1.0
  PRINT *, IEEE_REM(3.0,2.0)  ! Prints -1.0
  PRINT *, IEEE_REM(5.0,2.0)  ! Prints  1.0
ENDIF

IEEE_RINT(X)

An elemental IEEE function. Rounds to an integer value according to the current rounding mode.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real.

Result Type

Where the result is the same type and kind as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If the result has the value zero, the sign is that of X.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(1.1)) THEN
  CALL IEEE_SET_ROUNDING_MODE(IEEE_NEAREST)
  PRINT *, IEEE_RINT(1.1)       ! Prints 1.0
  CALL IEEE_SET_ROUNDING_MODE(IEEE_UP)
  PRINT *, IEEE_RINT(1.1)       ! Prints 2.0
ENDIF

IEEE_SCALB(X, I)

An elemental IEEE function. Returns X * 2I.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real and I is of type INTEGER.

Result Type

Where the result is the same type and kind as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X * 2I is representable as a normal number, then the result is a normal number.

If X is finite and X * 2I is too large the IEEE_OVERFLOW exception occurs. The result value is infinity with the sign of X.

If X * 2I is too small and there is a loss of accuracy, the IEEE_UNDERFLOW exception occurs. The result is the nearest representable number with the sign of X.

If X is infinite, the result is the same as X with no exception signals.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(1.0)) THEN
  PRINT *, IEEE_SCALB(1.0,2)       ! Prints 4.0
ENDIF

IEEE_SELECTED_REAL_KIND([P, R])

A transformational IEEE function. Returns a value of the kind type parameter of an IEEE real data type with decimal precision of at least P digits, and a decimal exponent range of at least R.

Module

IEEE_ARITHMETIC

Syntax

Where P and R are both scalar optional arguments of type integer.

Rules

If the kind type parameter is not available and the precision is not available, the result is -1. If the kind type parameter is not available and the exponent range is not available, the result is -2. If the kind type parameter is not available and if neither the precision or the exponent range is available, the result is -3.

If more than one kind type parameter value is applicable, the value returned is the one with the smallest decimal precision. If there are several values, the smallest of these kind values is returned.

Examples

IEEE_SELECTED_REAL_KIND(6,70) has the value KIND(0.0) 

IEEE_SET_FLAG(FLAG, FLAG_VALUE)

An IEEE subroutine. Assigns a value to an IEEE exception flag.

Module

IEEE_EXCEPTIONS

Syntax

Where FLAG is an INTENT(IN) scalar or array argument of type IEEE_FLAG_TYPE corresponding to the value of the flag to be set. FLAG_VALUE is an INTENT(IN) scalar or array argument of type logical, corresponding to the desired status of the exception flag. The value of FLAG_VALUE should be conformable with the value of FLAG.

Rules

If FLAG_VALUE is true, the exception flag specified by FLAG is set to signaling. Otherwise, the flag is set to quiet.

Each element of FLAG must have a unique value.

Examples

USE IEEE_EXCEPTIONS
CALL IEEE_SET_FLAG(IEEE_OVERFLOW, .TRUE.)
! IEEE_OVERFLOW is now signaling

IEEE_SET_HALTING_MODE(FLAG, HALTING)

An IEEE subroutine. Controls continuation or halting after an exception.

Module

IEEE_EXCEPTIONS

Syntax

Where FLAG is an INTENT(IN) scalar or array argument of type IEEE_FLAG_TYPE corresponding to the exception flag for which holding applies. HALTING is an INTENT(IN) scalar or array argument of type logical, corresponding to the desired halting status. By default exceptions will not cause halting in XL Fortran. The value of HALTING should be conformable with the value of FLAG.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If you use the -qflttrap=imprecise compiler option, halting is not precise and may occur after the exception has occurred.

If HALTING is true, the exception specified by FLAG will cause halting. Otherwise, execution will continue after the exception.

If your code sets the halting mode to true for an exception flag and you do not use the -qflttrap=enable option when compiling the entire program, the program will produce unexpected results if exceptions occur. See the User's Guide for further information.

Each element of FLAG must have a unique value.

Examples

USE IEEE_EXCEPTIONS
CALL IEEE_SET_HALTING_MODE(IEEE_DIVIDE_BY_ZERO, .TRUE.)
REAL :: X = 1.0 / 0.0
! Program will halt with a divide-by-zero exception

IEEE_SET_ROUNDING_MODE (ROUND_VALUE)

An IEEE subroutine. Sets the current rounding mode.

Module

IEEE_ARITHMETIC

Syntax

Where ROUND_VALUE is an INTENT(IN) argument of type IEEE_ROUND_TYPE specifying the rounding mode.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_ROUNDING (ROUND_VALUE, X) must return with a value of true.

The compilation unit calling this program must be compiled with the -qfloat=rrm compiler option.

All compilation units calling programs compiled with the -qfloat=rrm compiler option must also be compiled with this option.

Examples

USE IEEE_ARITHMETIC
IF (IEEE_SUPPORT_DATATYPE(1.1)) THEN
  CALL IEEE_SET_ROUNDING_MODE(IEEE_NEAREST)
  PRINT *, IEEE_RINT(1.1)       ! Prints 1.0
  CALL IEEE_SET_ROUNDING_MODE(IEEE_UP)
  PRINT *, IEEE_RINT(1.1)       ! Prints 2.0
ENDIF

IEEE_SET_STATUS(STATUS_VALUE)

An elemental IEEE subroutine. Restores the value of the floating-point status.

Module

IEEE_ARITHMETIC

Syntax

Where STATUS_VALUE is an INTENT(IN) argument of type IEEE_STATUS_TYPE specifying the floating-point status.

Rules

STATUS_VALUE must have been set previously by IEEE_GET_STATUS.

IEEE_SUPPORT_DATATYPE(X)

An inquiry IEEE function. Determines whether the current implementation supports IEEE arithmetic. Support means using an IEEE data format and performing the binary operations of +, -, and * as in the IEEE standard whenever the operands and result all have normal values.

Note:
NaN and Infinity are not fully supported for REAL(16). Arithmetic operations do not necessarily propagate these values.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

If X is absent, the function returns a value of false.

If X is present and REAL(16), the function returns a value of false. Otherwise the function returns true.

Examples

USE IEEE_ARITHMETIC
TYPE(IEEE_STATUS_TYPE) STATUS_VALUE
...
CALL IEEE_GET_STATUS(STATUS_VALUE)   ! Get status of all exception flags
CALL IEEE_SET_FLAG(IEEE_ALL,.FALSE.) ! Set all exception flags to quiet
... ! calculation involving exception handling
CALL IEEE_SET_STATUS(STATUS_VALUE)   ! Restore the flags

IEEE_SUPPORT_DENORMAL(X)

An inquiry IEEE function. Determines whether the current implementation supports denormalized numbers.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

The result has a value of true if the implementation supports arithmetic operations and assignments with denormalized numbers for all arguments of type real where X is absent, or for real variables of the same kind type parameter as X. Otherwise, the result has a value of false.

IEEE_SUPPORT_DIVIDE(X)

An inquiry IEEE function. Determines whether the current implementation supports division to the accuracy of the IEEE standard.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

The result has a value of true if the implementation supports division with the accuracy specified by the IEEE standard for all arguments of type real where X is absent, or for real variables of the same kind type parameter as X. Otherwise, the result has a value of false.

IEEE_SUPPORT_FLAG(FLAG, X)

An inquiry IEEE function. Determines whether the current implementation supports an exception.

Module

IEEE_EXCEPTIONS

Syntax

Where FLAG is a scalar argument of IEEE_FLAG_TYPE. X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

The result has a value of true if the implementation supports detection of the exception specified for all arguments of type real where X is absent, or for real variables of the same kind type parameter as X. Otherwise, the result has a value of false.

If X is absent, the result has a value of false.

If X is present and of type REAL(16), the result has a value of false. Otherwise the result has a value of true.

IEEE_SUPPORT_HALTING(FLAG)

An inquiry IEEE function. Determines whether the current implementation supports the ability to abort or continue execution after an exception occurs. Support by the current implementation includes the ability to change the halting mode using IEEE_SET_HALTING(FLAG).

Module

IEEE_EXCEPTIONS

Syntax

Where FLAG is an INTENT(IN) argument of IEEE_FLAG_TYPE.

Result Type

The result is a scalar of type default logical.

Rules

The result returns with a value of true for all flags.

IEEE_SUPPORT_INF(X)

An inquiry IEEE function. Support indicates that IEEE infinity behavior for unary and binary operations, including those defined by intrinsic functions and by functions in intrinsic modules, complies with the IEEE standard.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

The result has a value of true if the implementation supports IEEE positive and negative infinities for all arguments of type real where X is absent, or for real variables of the same kind type parameter as X. Otherwise, the result has a value of false.

If X is of type REAL(16), the result has a value of false. Otherwise the result has a value of true.

IEEE_SUPPORT_IO(X)

An inquiry IEEE function. Determines whether the current implementation supports IEEE base conversion rounding during formatted input/output. Support refers the ability to do IEEE base conversion during formatted input/output as described in the IEEE standard for the modes IEEE_UP, IEEE_DOWN, IEEE_ZERO, and IEEE_NEAREST for all arguments of type real where X is absent, or for real variables of the same kind type parameter as X.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X is present and of type REAL(16), the result has a value of false. Otherwise, the result returns a value of true.

IEEE_SUPPORT_NAN(X)

An inquiry IEEE function. Determines whether the current implementation supports the IEEE Not-a-Number facility. Support indicates that IEEE NaN behavior for unary and binary operations, including those defined by intrinsic functions and by functions in intrinsic modules, conforms to the IEEE standard.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X is absent, the result has a value of false.

If X is present and of type REAL(16), the result has a value of false. Otherwise the result returns a value of true.

IEEE_SUPPORT_ROUNDING (ROUND_VALUE, X)

An inquiry IEEE function. Determines whether the current implementation supports a particular rounding mode for arguments of type real. Support indicates the ability to change the rounding mode using IEEE_SET_ROUNDING_MODE.

Module

IEEE_ARITHMETIC

Syntax

Where ROUND_VALUE is a scalar argument of IEEE_ROUND_TYPE. X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X is absent, the result has a value of true if the implementation supports the rounding mode defined by ROUND_VALUE for all arguments of type real. Otherwise, it has a value of false.

If X is present, the result returns a value of true if the implementation supports the rounding mode defined by ROUND_VALUE for real variables of the same kind type parameter as X. Otherwise, the result has a value of false.

If X is present and of type REAL(16), the result returns a value of false when ROUND_VALUE has a value of IEEE_NEAREST. Otherwise the result returns a value of true.

If ROUND_VALUE has a value of IEEE_OTHER the result has a value of false.

IEEE_SUPPORT_SQRT(X)

An inquiry IEEE function. Determines whether the current implementation supports the SQRT as defined by the IEEE standard.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

If X is absent, the result returns a value of true if SQRT adheres to IEEE conventions for all variables of type REAL. Otherwise, the result has a value of false.

If X is present, the result returns a value of true if SQRT adheres to IEEE conventions for all variables of type REAL with the same kind type parameter as X. Otherwise, the result has a value of false.

If X is present and of type REAL(16), the result has a value of false. Otherwise the result returns a value of true.

IEEE_SUPPORT_STANDARD(X)

An inquiry IEEE function. Determines whether all facilities defined in the Fortran 2000 draft standard are supported.

Module

IEEE_ARITHMETIC

Syntax

Where X is an optional scalar or array valued argument of type real.

Result Type

The result is a scalar of type default logical.

Rules

If X is absent, the result returns a value of false since XL Fortran supports REAL(16).

If X is present, the result returns a value of true if the following functions also return true:

Otherwise, the result returns a value of false.

IEEE_UNORDERED(X, Y)

An elemental IEEE unordered function.

Module

IEEE_ARITHMETIC

Syntax

Where X and Y are of type real.

Result Type

The result is of type default logical.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_DATATYPE(Y) must return with a value of true.

Unordered function that returns with a value of true if X or Y is a NaN. Otherwise the function returns with a value of false.

Examples

REAL X,Y 
X = 0.0, 
Y = -1.0
Y = IEEE_VALUE(Y, IEEE_QUIET_NAN)
 

IEEE_VALUE(X, CLASS)

An elemental IEEE function. Generates an IEEE value as specified by CLASS.

Note:
Implementation of this function is platform and compiler dependent due to variances in NaN processing on differing platforms. A NaN value saved in a binary file that is read on a different platform than the one that generated the value will have unspecified results.

Module

IEEE_ARITHMETIC

Syntax

Where X is of type real. CLASS is of type IEEE_CLASS_TYPE.

Result Type

The result is of the same type and kind as X.

Rules

To ensure compliance with the Fortran 2000 draft standard, the IEEE_SUPPORT_DATATYPE(X) must return with a value of true.

IEEE_SUPPORT_NAN(X) must be true if the value of CLASS is IEEE_SIGNALING_NAN or IEEE_QUIET_NAN.

IEEE_SUPPORT_INF(X) must be true if the value of CLASS is IEEE_NEGATIVE_INF or IEEE_POSITIVE_INF.

IEEE_SUPPORT_DENORMAL(X) must be true if the value of CLASS is IEEE_NEGATIVE_DENORMAL or IEEE_POSITIVE_DENORMAL.

Multiple calls of IEEE_VALUE(X, CLASS) return the same result for a particular value of X, if kind type parameter and CLASS remain the same.

If a compilation unit calls this program with a CLASS value of IEEE_SIGNALING_NAN, the compilation unit must be compiled with the -qfloat=nans compiler option.

Examples

REAL :: X
IF (IEEE_SUPPORT_DATATYPE(X)) THEN
  X = IEEE_VALUE(X, IEEE_NEGATIVE_INF)
  PRINT *, X                    ! Prints -INF
ENDIF


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]