Always false float comparisons

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 28 16:28:58 PDT 2017


On 14.05.2016 02:49, Timon Gehr wrote:
> On 13.05.2016 23:35, Walter Bright wrote:
>> On 5/13/2016 12:48 PM, Timon Gehr wrote:
>>> IMO the compiler should never be allowed to use a precision different
>>> from the one specified.
>>
>> I take it you've never been bitten by accumulated errors :-)
>> ...
> 
> If that was the case it would be because I explicitly ask for high 
> precision if I need it.
> 
> If the compiler using or not using a higher precision magically fixes an 
> actual issue with accumulated errors, that means the correctness of the 
> code is dependent on something hidden, that you are not aware of, and 
> that could break any time, for example at a time when you really don't 
> have time to track it down.
> 
>> Reduced precision is only useful for storage formats and increasing
>> speed.  If a less accurate result is desired, your algorithm is wrong.
> 
> Nonsense. That might be true for your use cases. Others might actually 
> depend on IEE 754 semantics in non-trivial ways. Higher precision for 
> temporaries does not imply higher accuracy for the overall computation.
> 
> E.g., correctness of double-double arithmetic is crucially dependent on 
> correct rounding semantics for double:
> https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic

We finally have someone on D.learn who is running into this exact problem:

http://forum.dlang.org/post/vimvfarzqkcmbvtnznrf@forum.dlang.org



More information about the Digitalmars-d mailing list