float equality

Walter Bright newshound2 at digitalmars.com
Sat Feb 19 22:59:25 PST 2011


Jonathan M Davis wrote:
> Honestly, the more that I learn about and deal with floating point numbers, the 
> more I wonder why we don't just use fixed point. Obviously that can be a bit 
> limiting for the size of the number (on either side of the decimal) - 
> particularly in 32-bit land - but with 64-bit numbers, it sounds increasingly 
> reasonable given all of the issues with floating point values. Ideally, I 
> suppose, you'd have both, but the CPU specifically supports floating point (I 
> don't know about fixed point), and I don't think that I've ever used a language 
> which really had fixed point values (unless you count integers as fixed point with 
> no digits to the right of the decimal).

Fixed point won't solve your problems.

The engineers who got caught by roundoff errors at Boeing were using 
calculators, not computers. They'd also get caught with roundoff errors using 
slide rules, graphical methods, and hand calculation.

At Caltech, where we used calculators, we would get hammered if we did not carry 
through all equations symbolically to the final one, and then calculate it. The 
reason is because often terms drop away doing that, and hence roundoff error is 
minimized.

We'd also get hammered if the numeric answers were not "reasonable", i.e. coming 
up with negative mass or other nonsense. By hammered, I mean you got an 
automatic zero on the problem.

Bottom line is, if you work with numbers, you've got to pay attention to 
roundoff error and other mechanical issues in deriving answers, whether you're 
using a calculator, a computer, a slide rule, by hand, whatever. If you don't, 
you are incompetent.


More information about the Digitalmars-d mailing list