[OT] The Usual Arithmetic Confusions

Walter Bright newshound2 at digitalmars.com
Sat Feb 5 23:04:26 UTC 2022


On 2/5/2022 2:52 PM, Timon Gehr wrote:
> On 05.02.22 23:01, Walter Bright wrote:
>> On 2/5/2022 6:54 AM, Timon Gehr wrote:
>>> I get that the entire x87 design is pretty bad and so there are trade-offs, 
>>> but as it has now been deprecated, I hope this kind of second-guessing will 
>>> become a thing of the past entirely. In the meantime, I will avoid using DMD 
>>> for anything that requires floating-point arithmetic.
>>
>> I'm not sure how you concluded that.
> 
> Maybe my information is outdated. (This has come up many times in the past, and 
> you have traditionally argued in favor of not respecting the specified precision.)
> 
>> DMD now rounds float calculations to float with the x87, despite the cost in 
>> speed.
>> ...
> 
> That's great news, but the opposite is still in the spec:
> https://dlang.org/spec/float.html

That'll be fixed.


> In any case, AFAIK CTFE still relies on this leeway (in all compilers, as it's a 
> frontend feature).

I don't think it does, but I'll have to check.


>> If the CPU has SIMD float instructions on it, that is used instead of the x87, 
>> just like what every other compiler does.
> 
> My current understanding is that this can change at any point in time without it 
> being considered a breaking change, and that DMD is more likely to do this than 
> LDC.

Highly unlikely. (Neither the C nor the C++ standards require this behavior, 
either, AFAIK, so you shouldn't use any other compilers, either.)


More information about the Digitalmars-d mailing list