Casting double to ulong weirdness
Justin Whear via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 24 11:16:44 PDT 2015
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.
$ cat test.c
#include "stdio.h"
int main(int nargs, char** args)
{
double x = 1.2;
printf("%.20f\n", x);
}
$ clang test.c && ./a.out
1.19999999999999995559
More information about the Digitalmars-d
mailing list