On Saturday, 9 February 2019 at 03:28:24 UTC, Adam D. Ruppe wrote:
On Saturday, 9 February 2019 at 03:21:51 UTC, Murilo wrote:
Now, changing a little bit the subject. All FPs in D turn out
to be printed differently than they are in C and in C it comes
out a little more precise than in D. Is this really supposed
to happen?
Like I said in my first message, the D default rounds off more
than the C default. This usually results in more readable stuff
- the extra noise at the end is not that helpful in most cases.
But you can change this with the format specifiers (use
`writefln` instead of `writeln` and give a precision argument)
or, of course, you can use the same C printf function from D.
Thanks but here is the situation, I use printf("%.20f", 0.1); in
both C and D, C returns 0.10000000000000000555 whereas D returns
0.10000000000000001000. So I understand your point, D rounds off
more, but that causes loss of precision, isn't that something bad
if you are working with math and physics for example?