The standard C library has 4 floating point rounding modes available through cfenv.h. These are now available in C++11 through the header file cfenv.

The 4 floating point rounding modes are:

FE_TONEAREST
FE_DOWNWARD
FE_UPWARD
FE_TOWARDZERO

FE_TONEAREST rounds to the nearest integer. If the floating point value is exactly midway between two integers, then it does round half to even. The rest of the rounding modes are self explanatory.

None of the 4 rounding modes is equivalent to the round half away from zero which the round method does.

Anything to do with floating point operations is dependent on the FPU of the processor. So, the availability of these rounding modes and their values are highly dependent on the FPU of your processor.

On my x86_64 computer, all the 4 rounding modes were available and the values of these rounding modes were found to be:

## One thought on “Floating point rounding modes in C++11”