ieee_set_rounding_mode

Date:

10-12-2011

NAME

IEEE_SET_ROUNDING_MODE - Alters the current floating-point rounding mode state

SYNOPSIS

CALL IEEE_SET_ROUNDING_MODE ([ROUND_VALUE=]round_value)
   TYPE(IEEE_ROUND_TYPE) :: round_value

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

IEEE Standard for Binary Floating-point Arithmetic

DESCRIPTION

The IEEE_SET_ROUNDING_MODE intrinsic subroutine is typically used to alter the current floating-point rounding mode state and to restore the caller’s floating-point rounding mode just before exiting a procedure. It accepts the following argument:

round_value

Must be scalar and of type TYPE(IEEE_ROUND_TYPE). It is an INTENT(IN) argument.

  • The floating-point rounding mode is set to round_value.

  • round_value must have one of the values represented by the following named constants:

    • IEEE_NEAREST

    • IEEE_UP

    • IEEE_TO_ZERO

    • IEEE_DOWN

The round_value argument is assumed to have been set through an invocation of ieee_get_rounding_mode(3i).

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

EXAMPLES

USE, INTRINSIC :: IEEE_ARITHMETIC
TYPE(IEEE_ROUND_TYPE) save_rounding_mode
! Save the current rounding mode then change the rounding mode
! to round up.
CALL IEEE_GET_ROUNDING_MODE(save_rounding_mode)
CALL IEEE_SET_ROUNDING_MODE(IEEE_UP)
! Calculate the upper bound on sum.
DO i = 1, n
xup(i)  = y(i) + z(i)
END DO
! Reset to round to negative infinity mode.
CALL IEEE_SET_ROUNDING_MODE(IEEE_DOWN)
! Calculate lower bound on sum.
DO i = 1, n
xdn(i) = y(i) + z(i)
END DO
! Restore original rounding mode and return to the caller.
CALL IEEE_SET_ROUNDING_MODE(save_rounding_mode)

SEE ALSO

ieee_get_rounding_mode(3i), ieee_support_rounding(3i)