delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/04/05:44:34

Date: Wed, 4 Feb 1998 11:29:10 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <eldredge AT ap DOT net>
cc: John Luebs <sales AT luebsphoto DOT com>, djgpp AT delorie DOT com
Subject: Re: division by 0
In-Reply-To: <199802040223.SAA05007@adit.ap.net>
Message-ID: <Pine.SUN.3.91.980204112518.25326A@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019