Mail Archives: djgpp/1998/02/04/05:44:34
On Tue, 3 Feb 1998, Nate Eldredge wrote:
> Is there some portable way to say what kind of exceptions you want?
> Sometimes a program would want some masked (like if I use NaN's), but others
> not (if divide by 0 would be a bug in my code). `_control87' can obviously
> do this, but equally obviously it won't work on anything but a 386/7.
AFAIK, these issues are highly non-portable. I would imagine that some
platforms would not even let you control this (e.g. if the OS kernel
wants this to be its prerogative).
The most portable way is to assume that no exceptions occur and you get
the IEEE-standard NaNs and +/-Inf. Also, write your own `matherr'
function that copes with disasters in math functions. This setup
corresponds with all numeric exceptions masked off in the x86 environment.
If you still fear the exceptions, install a handler for SIGFPE, but
usually it cannot do much except exiting with some helpful message.
- Raw text -