cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/03/09:13:12

Date: Tue, 3 Feb 1998 12:27:53 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: John Luebs <sales AT luebsphoto DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: division by 0
In-Reply-To: <01bd304c$61945240$a3b972ce@comp>
Message-ID: <Pine.SUN.3.91.980203122256.21682f-100000@is>
MIME-Version: 1.0

On 3 Feb 1998, John Luebs wrote:

> 2) The only way (should be #1 now!!!). Make a divide function:
> float divide(float a, float b)
> {
> 	if(!b) return MAX_FLOAT; /* if you never use the maximum then this may
> work as "inf" */
> 	else return a/b;
> }

For floating-point code you don't need this at all, as x87 will do this
for you if you set it up to mask off all FP exceptions (see `_control87'
in the library).  If you do that, you will automatically get Inf, which is
better than FLT_MAX, since the latter is a valid number.  (DJGPP v2.02 
will set up x87 to mask all exception by default, btw.) 

But if you need to do the same for integer code, you cannot do it 
easily.  Obviously, replacing every division with a function call would 
be terribly slow.

- Raw text -


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