Mail Archives: djgpp/1998/02/03/09:13:12
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 -