So why double to float conversion is implicit ?

Fool fool at dlang.org
Wed Oct 25 16:16:23 UTC 2017


On Tuesday, 24 October 2017 at 17:54:55 UTC, Andrei Alexandrescu 
wrote:
> For the record, I remember the points made:
>
> * When converting across integral types, any failed coercion 
> yields a value essentially unrelated to the source. So we 
> deemed these unacceptable.
>
> * When converting int to float or long to double, there is a 
> loss of accuracy - a float can represent all ints, but some of 
> them will be represented with approximation. But here there 
> _is_ a notion of "I'm okay with an approximation". So we deemed 
> these acceptable.
>
> * When converting double to float, again there is a loss of 
> accuracy and also the risk of too large values. But there's 
> never a gross mistake - too large values are converted to 
> infinity, and otherwise an approximation occurs. This was also 
> deemed acceptable.
>
> Folks with other design sensibilities might choose differently. 
> Actually I wasn't on board with this decision, but I accepted 
> it. But deeming it absurd is a bit of a stretch.

Thank you for the explanation. I understand the reasoning. It 
seems strange to me that D is aiming at security concerning 
memory management and integer arithmetic but not with respect to 
the processing of floating-point entities.

To clarify: this topic was not the reason but only the occasion 
for my ranting. It's just a pointed expression of my personal 
impression that I got from a few discussions here.

I would like to stress that there are also people in the 
community who do not reflexively dismiss every critical objection 
from the outside. In this context, "problem realized, won't fix 
nevertheless" seems to be a much better answer than denying 
existence of problems brought up by new or less known people.


More information about the Digitalmars-d mailing list