[mysterious bug in C++ complex class resolved after using the "improve
floating point consistency" compile flag]

Compiler documentation...

>By default, the compiler uses the coprocessor's 80-bit registers to>hold the intermediate results of floating-point calculations. This>increases program speed and decreases program size. However, because>the calculation involves floating-point data types that are>represented in memory by less than 80 bits, carrying the extra bits of>precision (80 bits minus the number of bits in a smaller>floating-point type) through a lengthy calculation can produce>inconsistent results.

On the x86 it is possible to write out 80 bit double extended values
to memory, although writing out 64 bit double values is faster.

>To trust or not to trust?

>Quinn Tyler Jackson

>[It's pretty cheezy, but I have to admit that precision problems like this>are a chronic problem in floating point code. -John]

Extended precision floating point gets a bad name precisely because
languages and compilers don't give a name to that format. Some
compilers use extended precision without the knowledge or consent of
the programmer, leading to confusing results. If the compiler in
question mapped the x86's double extended format to the long double
type, the programmer could indicate when and where extended precision
should be used. Even if not used by general programmers, having
extended precision makes implementing the math library easier.

These kinds of unwanted extra-precision bugs are not new; the 680x0
based Sun III compilers could introduce the same sort of surprises
(these surprises also appeared even earlier on the GE635). In an
effort to speed up Java's floating point the x86, Sun is proposing to
allow these precision anomalies into Java
(http://java.sun.com/feedback/fp.html). If you want to let Sun know
that isn't such a great idea, they have an email address for comments,
javasoft-spec-comments@eng.sun.com.

-Joe Darcy
darcy@cs.berkeley.edu
[I've never understood why people are so eager to have fast wrong
answers. -John]
--