Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Floating point rounding modes in C++11

📅 2018-Sep-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

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.

FE_TONEAREST
FE_DOWNWARD
FE_UPWARD
FE_TOWARDZERO
#define FE_TONEAREST  0x000
#define FE_DOWNWARD   0x400
#define FE_UPWARD     0x800
#define FE_TOWARDZERO 0xC00