Date: Wed, 4 Feb 1998 11:29:10 +0200 (IST) From: Eli Zaretskii To: Nate Eldredge cc: John Luebs , djgpp AT delorie DOT com Subject: Re: division by 0 In-Reply-To: <199802040223.SAA05007@adit.ap.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.