Always false float comparisons
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 18 10:44:41 PDT 2016
On 17.05.2016 21:31, deadalnix wrote:
> On Tuesday, 17 May 2016 at 18:08:47 UTC, Timon Gehr wrote:
>> Right. Hence, the 80-bit CTFE results have to be converted to the
>> final precision at some point in order to commence the runtime
>> computation. This means that additional rounding happens, which was
>> not present in the original program. The additional total roundoff
>> error this introduces can exceed the roundoff error you would have
>> suffered by using the lower precision in the first place, sometimes
>> completely defeating precision-enhancing improvements to an algorithm.
>>
>
> WAT ? Is that really possible ?
>
Yes, I'm sorry, but this can and does happen.
Consider http://forum.dlang.org/post/nhi7m4$css$1@digitalmars.com
You can build similar examples involving only CTFE. Refer to
http://forum.dlang.org/post/nhi9gh$fa4$1@digitalmars.com for an
explanation of one case where this can happen. (I had actually written
that post three days ago, and assumed that it had been posted to the
newsgroup, but something went wrong, apparently.)
More information about the Digitalmars-d
mailing list