Date: Tue, 3 Feb 1998 12:27:53 +0200 (IST) From: Eli Zaretskii To: John Luebs cc: djgpp AT delorie DOT com Subject: Re: division by 0 In-Reply-To: <01bd304c$61945240$a3b972ce@comp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.