|
|
The floating point arithmetic provides four rounding modes that
affect the result of most floating point operations.
(These modes
are defined in the header ieeefp.h):
FP_RN round to nearest representable number, tie -> even
FP_RP round toward plus infinity
FP_RM round toward minus infinity
FP_RZ round toward zero (truncate)
You can check the current rounding mode with the function
fp_rnd fpgetround(void); /* return current rounding mode */You can change the rounding mode for floating point operations with the function:
fp_rnd fpsetround(fp_rnd); /* set rounding mode, */ /* return previous */(fp_rnd is an enumeration type with the enumeration constants listed and described above. The values for these constants are in ieeefp.h.)
The default rounding mode is round-to-nearest. In C and FORTRAN (F77), floating point to integer conversions are always done by truncation, and the current rounding mode has no effect on these operations.
For more information on fpgetround and fpsetround, see fpgetround(S).