HP-UX Floating-Point Guide

130 Chapter 5
Manipulating the Floating-Point Status Register
Run-Time Mode Control: The fenv(5) Suite
The fields not manipulated by the fenv(5) functions are as follows:
C The Compare bit.
Res Reserved for future use.
Model,
Revision The Model and Revision fields contain values that
correspond to various implementations of HP 9000
floating-point coprocessors.
T The Delayed Trap bit.
Rounding Mode: fegetround and fesetround
The functions fegetround and fesetround allow you to retrieve or
change the rounding mode for floating-point operations. The declarations
for these functions are as follows:
int fegetround(void);
int fesetround(int round);
The value returned by fegetround and the argument of fesetround
match one of the rounding direction macros defined in fenv.h. The
rounding direction macros are as follows:
FE_TONEAREST Round to nearest
FE_TOWARDZERO Round toward zero
FE_UPWARD Round toward positive infinity
FE_DOWNWARD Round toward negative infinity
The fegetround function returns the current rounding mode. By
default, the rounding mode is FE_TONEAREST.
The fesetround function sets the rounding mode to the specified value.
It returns a nonzero value if and only if the argument matches a
rounding direction macro.
The following C program uses fesetround and fegetround to show
how the rounding mode affects the result of an overflow (see Table 2-11
on page 57).