[comp.sys.mac] FP Accuracy

dgold@apple.com (David Goldsmith) (07/29/89)

In article <4134@utastro.UUCP> bill@utastro.UUCP (William H. Jefferys) 
writes:
> Here is the bug. It shows up on a Mac+ with no coprocessor.
> It does NOT show up on a Mac II. I don't know about the SE,
> but I expect it will show up there too (anyone want to
> try it?)
> 
> Compute the square root of 0.999975. On a Plus, EXCEL
> gives the incorrect value 0.9999875. The correct value
> is 0.9999749992187, a difference of 1.6e-10. This may
> not sound like much, but for the application I was
> doing when I discovered this, it was highly significant.
> Normally, EXCEL gives 16 digit accuracy for the square 
> root.

I'm sympathetic to Mr. Jefferys' plight, but I can't resist
the opportunity to make a point from this.  Many people have criticized
Apple's SANE package for being too slow, and some of these criticisms are
justified; in fact, based on feedback our numerics group is looking at ways
to speed the package up.  The point I want to make, though, is that people
often act as if speed were the only consideration in developing a floating
point package.  The reason this bug occurs on the Mac Plus but not the Mac
II is that on the Mac II, Excel uses the 68881, which performs
IEEE-compliant computations.  However, on the Mac Plus and SE, Excel uses
its own custom floating point package, because the developers considered
SANE to be too slow.  As a result, it gives different answers on the two
machines.

The primary goal for SANE was to provide a robust, IEEE-compliant numeric
package *which would give the same answer on all Apple machines*.  Because
SANE is IEEE-compliant, it gives reasonable answers in many situations
where ad-hoc floating point packages quietly produce meaningless garbage.

The bottom line is, SANE could be faster, and work is progressing in that
direction.  But it doesn't matter how fast you get the answer if it's
wrong.  How many spreadsheet users out there are producing -- and making
use of -- erroneous answers because of the quest for speed at all costs?


David Goldsmith                                           Apple Computer, 
Inc.
AppleLink: GOLDSMITH1    BIX: dgoldsmith         20525 Mariani Avenue, MS: 
77A
UUCP: {nsc,dual,sun,voder,ucbvax!mtxinu}!apple!dgold       Cupertino, CA 
95014
CSNET: dgold@apple.com