SETCONTROLFPQQ (ia32 only)

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

Module: USE DFLIB

Syntax

CALL SETCONTROLFPQQ (controlword)

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

The floating-point control word specifies how various exception conditions are handled by the floating-point math coprocessor, sets the floating-point precision, and specifies the floating-point rounding mechanism used.

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$MCW_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.

Setting the floating-point precision and rounding mechanism can be useful if you are reusing old code that is sensitive to the floating-point precision standard used and you want to get the same results as on the old machine.

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. If you need to change the control word, always use SETCONTROLFPQQ to make sure that special routines handling floating-point stack exceptions and abnormal propagation work correctly.

For a full discussion of the floating-point control word, exceptions, and error handling, see The Floating-Point Environment in the Programmer's Guide.

The Visual Fortran exception handler allows for software masking of invalid operations, but does not allow the math chip to mask them. If you choose to use the software masking, be aware that this can affect program performance if you compile code written for Visual Fortran with another compiler.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: GETCONTROLFPQQ, GETSTATUSFPQQ, LCWRQQ, SCWRQQ, CLEARSTATUSFPQQ

Example

 USE DFLIB
 INTEGER(2) status, control, controlo

 CALL GETCONTROLFPQQ(control)
 WRITE (*, 9000) 'Control word: ', control
 !     Save old control word
 controlo = control
 !     Clear all flags
 control = control .AND. #0000
 !     Set new control to round up
 control = control .OR. FPCW$UP
 CALL SETCONTROLFPQQ(control)
 CALL GETCONTROLFPQQ(control)
 WRITE (*, 9000) 'Control word: ', control
 9000 FORMAT (1X, A, Z4)
 END