Reads and sets the IEEE decimal floating-point rounding mode.
Standard C Library (libc.a)
#include <fenv.h>
int fe_dec_getround ();
int fe_dec_setround (RoundMode);
int RoundMode
The fe_dec_getround subroutine returns the current rounding mode. The fe_dec_setround subroutine changes the rounding mode to the RoundMode parameter and returns the value of zero if it successfully completes.
Decimal floating-point rounding occurs when the infinitely precise result of a decimal floating-point operation cannot be represented exactly in the destination decimal floating-point format. The IEEE Standard for decimal floating-point arithmetic defines five modes that round the floating-point numbers: round toward zero, round to nearest, round toward +INF, round toward -INF, and round to nearest ties away from zero. Once a rounding mode is selected, it affects all subsequent decimal floating-point operations until another rounding mode is selected.
fenv.h definition | ANSI value | Description |
---|---|---|
FE_DEC_TONEAREST | 0 | Round to nearest |
FE_DEC_TOWARDZERO | 1 | Round toward zero |
FE_DEC_UPWARD | 2 | Round toward +INF |
FE_DEC_DOWNWARD | 3 | Round toward -INF |
FE_DEC_TONEARESTFROMZERO | 4 | Round to nearest ties away from zero |
Item | Description |
---|---|
RoundMode | Specifies one of the following modes: FE_DEC_TOWARDZERO, FE_DEC_TONEAREST, FE_DEC_UPWARD, FE_DEC_DOWNWARD, FE_DEC_TONEARESTFROMZERO. |
On successful completion, the fe_dec_getround subroutine returns the current rounding mode. Otherwise , it returns -1.
On successful completion, the fe_dec_setround subroutine returns the value of zero. Otherwise, it returns -1.