FESETROUND(3)

NAME
fesetround, fegetround - floating point rounding mode control

SYNOPSIS
#include <fenv.h>
int fegetround(void);
int fesetround(int round);

DESCRIPTION
These functions control the floating point rounding mode. One can use fegetround to determine the rounding mode currently in effect and fesetround the change the rounding mode. Four rounding modes are recognized: FE_TONEAREST, FE_DOWNWARD, FE_UPWARD and FE_TOWARDZERO. When rounding a value x to an integer n, the following approaches can be taken: FE_TONEAREST selects the n for which abs(fIx - n) is minimal, preferring an even n if there are two possibilities; FE_DOWNWARD selects the largest n for which n <= fIx; FE_UPWARD selects the smallest n for which n >= fIx; and FE_TOWARDZERO selects n with the largest abs(n) for which abs(n) <= abs(x).

RETURN VALUE
fegetround returns the current rounding mode. fesetround returns 0 if it was succesful in adjusting the rounding mode and -1 otherwise. The only possible reason for failure is an unsupported value for round, which is signalled by setting errno to EINVAL.

DIAGNOSTICS
fegetround always succeeds. The only possible reason for failure of fesetround is an unsupported value for round, which is signalled by setting errno to EINVAL.

SEE ALSO
nearbyint(3)