GETCONTROLFPQQ (ia32 only)

Run-Time Subroutine: Returns the floating-point processor control word. This routine is only available on ia32 processors.

Module: USE DFLIB

Syntax

CALL GETCONTROLFPQQ (controlword)

controlword
(Output) INTEGER(2). Floating-point processor control word.

The floating-point control word is a bit flag that controls various modes of the floating-point coprocessor. The DFLIB.F90 module file (in the \DF98\INCLUDE subdirectory) contains constants defined for the control word as follows:

Parameter name Hex value Description
FPCW$MCW_IC #1000 Infinity control mask
FPCW$AFFINE #1000 Affine infinity
FPCW$PROJECTIVE #0000 Projective infinity
FPCW$MCW_PC #0300 Precision control mask
FPCW$64 #0300 64-bit precision
FPCW$53 #0200 53-bit precision
FPCW$24 #0000 24-bit precision
FPCW$MCW_RC #0C00 Rounding control mask
FPCW$CHOP #0C00 Truncate
FPCW$UP #0800 Round up
FPCW$DOWN #0400 Round down
FPCW$NEAR #0000 Round to nearest
FPCW$MSW_EM #003F Exception mask
FPCW$INVALID #0001 Allow invalid numbers
FPCW$DENORMAL #0002 Allow denormals (very small numbers)
FPCW$ZERODIVIDE #0004 Allow divide by zero
FPCW$OVERFLOW #0008 Allow overflow
FPCW$UNDERFLOW #0010 Allow underflow
FPCW$INEXACT #0020 Allow inexact precision

The defaults for the floating-point control word are 53-bit precision, round to nearest, and the denormal, underflow and inexact precision exceptions disabled. An exception is disabled if its flag is set to 1 and enabled if its flag is cleared to 0. Exceptions can be disabled by setting the flags to 1 with SETCONTROLFPQQ.

If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes generate an appropriate special value (NaN or signed infinity), but the program continues.

You can find out which exceptions (if any) occurred by calling GETSTATUSFPQQ. If errors on floating-point exceptions are enabled (by clearing the flags to 0 with SETCONTROLFPQQ), the operating system generates an interrupt when the exception occurs. By default, these interrupts cause run-time errors, but you can capture the interrupts with SIGNALQQ and branch to your own error-handling routines.

You can use GETCONTROLFPQQ to retrieve the current control word and SETCONTROLFPQQ to change the control word. Most users do not need to change the default settings. For a full discussion of the floating-point control word, exceptions, and error handling, see The Floating-Point Environment in the Programmer's Guide.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: SETCONTROLFPQQ, GETSTATUSFPQQ, SIGNALQQ, MATHERRQQ, CLEARSTATUSFPQQ

Example

USE DFLIB
INTEGER(2) control
CALL GETCONTROLFPQQ (control)
     !if not rounding down
IF (IAND(control, FPCW$DOWN) .NE. FPCW$DOWN) THEN
  control = IAND(control, NOT(FPCW$MCW_RC)) ! clear all
                                            !  rounding
  control = IOR(control, FPCW$DOWN)         !  set to
                                            !  round down
  CALL SETCONTROLFPQQ(control)
END IF
END