Casting double to ulong weirdness

Warwick via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 24 11:34:54 PDT 2015


On Monday, 24 August 2015 at 18:16:44 UTC, Justin Whear wrote:
> On Mon, 24 Aug 2015 18:06:07 +0000, rumbu wrote:
>
>> BTW, 1.2 and 12.0 are directly representable as double
>> 
>> In C++:
>> 
>> printf("%.20f\r\n", 1.2);
>> printf("%.20f\r\n", 12.0);
>> 
>> will output:
>> 
>> 1.20000000000000000000 12.00000000000000000000
>> 
>> Either upcasting to real is the wrong decision here, either 
>> the writeln string conversion is wrong.
>
> No it's not, this must be some sort of constant-folding or 
> precision increase.

Maybe the constant folding is using a different rounding mode to 
the runtime?




More information about the Digitalmars-d mailing list