I\'m finding the floating-point model/error issues quite confusing. It\'s an area I\'m not familiar with and I\'m not a low level C/asm programmer, so I would appreciate a b
I've been struggling for achieving some information about handling floating point exceptions on linux and I can tell you what I learned: There are a few ways of enabling the exception mechanism:
fpu_control_t fw; _FPU_GETCW(fw); fw |=FE_ALL_EXCEPT; _FPU_SETCW(fw);
4.
> fenv_t envp; include bits/fenv.h
> fegetenv(&envp);
envp.__control_word |= ~_FPU_MASK_OM;
> fesetenv(&envp);
5.
> fpu_control_t cw;
> __asm__ ("fnstcw %0" : "=m" (*&cw));get config word
>cw |= ~FE_UNDERFLOW;
> __asm__ ("fldcw %0" : : "m" (*&cw));write config word
6.C++ mode: std::feclearexcept(FE_ALL_EXCEPT);
There are some useful links : http://frs.web.cern.ch/frs/Source/MAC_headers/fpu_control.h http://en.cppreference.com/w/cpp/numeric/fenv/fetestexcept http://technopark02.blogspot.ro/2005/10/handling-sigfpe.html