// For Linux machines
#include <fenv.h> // or <cfenv> but only for C++11
// Enable all exceptions except for INEXACT
feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT);
// More info at https://linux.die.net/man/3/feenableexcept
// For machines using SSE (Apple, etc.)
#include <xmmintrin.h>
// Disable only INVALID exception
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
// Enable the overflow and underflow exceptions and disable all others
_MM_SET_EXCEPTION_MASK(MM_MASK_OVERFLOW | _MM_MASK_UNDERFLOW)
// More info at http://technion.ac.il/doc/intel/compiler_c/main_cls/intref_cls/common/intref_sse_macro_readwrite_reg.htm