FP_CONTROL(3m,L) AIX Technical Reference FP_CONTROL(3m,L) ------------------------------------------------------------------------------- fp_control, fp_restore, fp_exmask, fp_exunmask, fp_round, fp_precision, fp_getcw, fp_getex, fp_getprecision, fp_getround, fp_getsw PURPOSE Sets and reads the 80387 control word. LIBRARY Math Library (libm.a) SYNTAX #include void fp_control(x) void fp_restore() unsigned int(x) void fp_exunmask(x) void fp_exmask(x) unsigned int(x) unsigned int(x) void fp_precision(x) void fp_round(x) unsigned int(x) unsigned int(x) unsigned int fp_getex() unsigned int fp_getcw() unsigned int fp_getround() unsigned int fp_getprecision() unsigned int fp_getsw() DESCRIPTION The fp_control subroutine takes as an argument a new value for the 80387 control word. The fp_exmask subroutine takes as an argument a bit mask corresponding to the bits in the 80387 control word interrupt mask fields. The bits are set in the control word causing the corresponding exceptions to be masked. The fp_exunmask subroutine takes as an argument a bit mask corresponding to the bits in the 80387 control word interrupt mask fields. The bits are cleared in the control word causing the corresponding exceptions to be unmasked. Processed November 7, 1990 FP_CONTROL(3m,L) 1 FP_CONTROL(3m,L) AIX Technical Reference FP_CONTROL(3m,L) The fp_round subroutine takes as an argument the bit patterns corresponding to the bits in the 80387 control word rounding mode field. The rounding mode is set to the pattern specified. The fp_precision subroutine takes as an argument the bit patterns corresponding to the bits in the 80387 control word precision mode field. The precision mode is set to the pattern specified. The fp_restore subroutine restores the 80387 control word to the value and mode which existed before any of the above described subroutines were called. If none of the above described subroutines were called, then no action is taken. The fp_getcw function returns the 80387 control word. The fp_getex function returns the exception mask portion of the 80387 control word. The fp_getround function returns the rounding mode portion of the 80387 control word. The fp_getprecision function returns the precision mode portion of the 80387 control word. The fp_getsw function returns the 80387 status word. As an aid in specifying the exception mask bits and the rounding and precision mode bit patterns, a set of definitions has been provided in the include file sys/fpcontrol.h. Exception masks: FPM_INV_OP 0x0001 FPM_DENORM 0x0002 FPM_DIVIDE_0 0x0004 FPM_OVERFLOW 0x0008 FPM_UNDERFLOW 0x0010 FPM_PRECISION 0x0020 Rounding modes: Processed November 7, 1990 FP_CONTROL(3m,L) 2 FP_CONTROL(3m,L) AIX Technical Reference FP_CONTROL(3m,L) FPR_NEAR 0x0000 FPR_DOWN 0x0400 FPR_UP 0x0800 FPR_CHOP 0x0c00 Precision modes: FPP_SINGLE 0x0000 FPP_DOUBLE 0x0200 FPP_EXTENDED 0x0300 These definitions can be used in a variety of ways. They can be ORed together to form an argument for the fp_control subroutine. If this is the case, any number of the exception mask symbols can be ORed with one of each of the rounding and precision mode values. For example: fp_control(FPP_SINGLE | FPR_UP | FPM_PRECISION | FP_OVERFLOW); selects single-precision results of calculations, rounding up to positive infinity, and mask exception interrupts for precision and overflow exceptions. The values can be used in the appropriate subroutine to modify a specific part of the 80387 control word. For example: fp_precision(FPP_EXTENDED) Note: Using a value with a subroutine which is not appropriate could produce an undesired result. The values can all be used with the fp_control subroutine as described above. The values supplied in fpcontrol.h can be used with the fp_getcw, fp_getround, fp_getex, and fp_getprecision subroutines to determine what is currently selected. For example: (fp_getex() & FPM_INV_OP) returns a nonzero value if the invalid operation exception is masked. (fp_getround() == FPR_CHOP) returns a nonzero value if chop (truncate towards zero) rounding mode is currently selected in the 80387 control word. Processed November 7, 1990 FP_CONTROL(3m,L) 3