On Sun, 20 Feb 2011 14:53:03 +0200, bearophile <bearophileh...@lycos.com> wrote:

Walter:

There's a total lack of evidence for that.

MISRA-C standard disallows the equality among FP values. I presume they have some serious evidence for their choices, but I don't know such evidence. Today MISRA-C is one of the most serious attempts at fixing the holes in C language to write more reliable code for the industry. MISRA-C standard is sometimes extreme and I don't suggest to follow everything they say, but I suggest to not totally ignore what it says about many C features.


1. Roundoff error is not of a fixed magnitude.

I meant to replace the nude FP equality with a function that has the shared number of mantissa bits as third required argument. And then perform the normal FP equality using the "is" operator.

I still think "==" should mean the exact equality test and must be consistent in language. Making something like almostEqual default is far more catastrophic than its current form. It doesn't solve the existing problem and create a basis for new form of problems.

If one doesn't know what floating point is and insists on using it, it is his own responsibility to face the consequences.

Regarding FP rounding errors, eventually it will be good to add to Phobos2 a library for Interval FP arithmetic, with trigonometric functions too, etc:
http://en.wikipedia.org/wiki/Interval_arithmetic

Bye,
bearophile

If only interval arithmetic would solve all the problems, i wouldn't hesitate dumping everything about FP.
But no, it comes with its shortcomings.

Reply via email to