Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 05:37:58 PDT 2016


On 5/16/2016 3:27 AM, Andrei Alexandrescu wrote:
> I'm not sure about this. My understanding is that all SSE has hardware for 32
> and 64 bit floats, and the the 80-bit hardware is pretty much cut-and-pasted
> from the x87 days without anyone really looking in improving it. And that's been
> the case for more than a decade. Is that correct?

I believe so.

> I'm looking for example at
> http://nicolas.limare.net/pro/notes/2014/12/12_arit_speed/ and see that on all
> Intel and compatible hardware, the speed of 80-bit floating point operations
> ranges between much slower and disastrously slower.

It's not a totally fair comparison. A matrix inversion algorithm that 
compensates for cumulative precision loss involves executing a lot more FP 
instructions (don't know the ratio).


> I think it's time to revisit our attitudes to floating point, which was formed
> last century in the heydays of x87. My perception is the world has moved to SSE
> and 32- and 64-bit float; the "real" type is a distraction for D; the whole
> let's do things in 128-bit during compilation is a time waster; and many of the
> original things we want to do with floating point are different without a
> distinction, and a further waste of our resources.

Some counter points:

1. Go uses 256 bit soft float for constant folding.

2. Speed is hardly the only criterion. Quickly getting the wrong answer (and not 
just a few bits off, but total loss of precision) is of no value.

3. Supporting 80 bit reals does not take away from the speed of floats/doubles 
at runtime.

4. Removing 80 bit reals will consume resources (adapting the test suite, 
rewriting the math library, ...).

5. Other languages not supporting it means D has a capability they don't have. 
My experience with selling products is that if you have an exclusive feature 
that a particular customer needs, it's a slam dunk sale.

6. My other experience with feature sets is if you drop things that make your 
product different, and concentrate on matching feature checklists with Major 
Brand X, customers go with Major Brand X.

7. 80 bit reals are there and they work. The support is mature, and is rarely 
worked on, i.e. it does not consume resources.

8. Removing it would break an unknown amount of code, and there's no reasonable 
workaround for those that rely on it.


More information about the Digitalmars-d mailing list