Real implicitly converts to float?

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 22 06:09:35 PDT 2016


On Wednesday, 22 June 2016 at 08:57:38 UTC, Guillaume Piolat 
wrote:
> On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote:
>> Is this intended behavior? I can't seem to find it documented 
>> anywhere, I would think the loss in precision would atleast be 
>> a warning.
>>
>> real x = 10;
>> float y = x; // No error or warning
>>
>> real to double and double to float also work.
>
> Intended behaviour (in TDPL and all), and same behaviour than C.
> I'm not sure of the reason.

That's a little disconcerting, would be nice if there was a 
compiler flag to give a warning on the precision loss.


More information about the Digitalmars-d-learn mailing list