On Tue, Dec 03, 2019 at 09:22:49AM +, Jan Hönig via Digitalmars-d-learn
wrote:
> Today i have stumbled on Hacker News into: https://0.30004.com/
>
> I am learning D, that's why i have to ask.
>
> Why does
>
> writefln("%.17f", .1+.2);
>
> not evaluate into:
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
Today i have stumbled on Hacker News into:
https://0.30004.com/
I am learning D, that's why i have to ask.
Why does
writefln("%.17f", .1+.2);
not evaluate into: 0.30004, like C++
but rather to:
On Tuesday, 3 December 2019 at 09:52:18 UTC, mipri wrote:
Most other languages give you the double result for very
reasonable historical reasons
Not only historical, it is also for numerical reasons. You can
get very unpredictable results if you do compares and compiletime
evalution is
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
not evaluate into: 0.30004, like C++
but rather to: 0.2
You get the same in C++ with:
#include
int main()
{
printf("%.17f",double(0.1L + 0.2L));
}
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
Today i have stumbled on Hacker News into:
https://0.30004.com/
I am learning D, that's why i have to ask.
Why does
writefln("%.17f", .1+.2);
not evaluate into: 0.30004, like C++
but rather to:
Today i have stumbled on Hacker News into:
https://0.30004.com/
I am learning D, that's why i have to ask.
Why does
writefln("%.17f", .1+.2);
not evaluate into: 0.30004, like C++
but rather to: 0.2
Many other languages evaluate to