Re: Win32: 0.0 / 0.0 = -NAN ? Win64: 0.0 / 0.0 = -1, #IND ?From: R Kym HorsellNewsgroups:
Sat, 30 Apr 2022 20:35 UTC
View all headers
Skybuck Flying <firstname.lastname@example.org> wrote:
When exception masks are all enabled to stop the processor from throwing floating point exceptions the following calculation produces a somewhat strange result:
0.0 / 0.0 = -nan
The 754 standard says a floating divide by zero may see the hardware generate
a +ve or -ve infinity. Result is a special NaN.
If the exception is caught s/w may replace the result with something more
sensible like 0 but it might also terminate the process.
The old hack to handle things like this is add a MachEps (smallest number
that is not treated as 0 when added) i.e. do x/(y+MachEps) .
In s/w you can sometimes do if(nan(result)) ... yourself.