Always false float comparisons

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun May 15 23:48:19 PDT 2016


On 16 May 2016 at 06:02, Manu via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> I'm not interested in C/C++, I gave some anecdotes where it's gone
> wrong for me too, but regardless; generally, they do match, and I
> can't think of a single modern example where that's not true. If you
> *select* fast-math, then you may generate code that doesn't match, but
> that's a deliberate selection.
>
> If I want 'real' math (in CTFE or otherwise), I will type "real". It
> is completely unreasonable to reinterpret the type that the user
> specified. CTFE should execute code the same way runtime would execute
> the code (without -ffast-math, and conformant ieee hardware). This is
> not a big ask.
>
> Incidentally, I made the mistake of mentioning this thread (due to my
> astonishment that CTFE ignores float types) out loud to my
> colleagues... and they actually started yelling violently out loud.
> One of them has now been on a 10 minute angry rant with elevated tone
> and waving his arms around about how he's been shafted by this sort
> behaviour so many times before. I wish I recorded it, I'd love to have
> submit it as evidence.

It isn't all bad.  Most the time you'll never notice. :-)

I can't think of a case of the top of my head where too much precision
caused a surprise.  It's always when there is too little:

https://issues.dlang.org/show_bug.cgi?id=16026

And I think the it's about that time of the year when I remind people
of gcc bug 323, and this lovely blog post.

http://blog.jwhitham.org/2015/04/gcc-bug-323-journey-to-heart-of.html


More information about the Digitalmars-d mailing list