Floating-Point arithmetic in dlang - Difference to other languages
Basile B.
b2.temp at gmx.com
Tue Dec 3 12:18:05 UTC 2019
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
> Today i have stumbled on Hacker News into:
> https://0.30000000000000004.com/
>
> I am learning D, that's why i have to ask.
>
> Why does
>
> writefln("%.17f", .1+.2);
>
> not evaluate into: 0.30000000000000004, like C++
> but rather to: 0.29999999999999999
>
> Many other languages evaluate to 0.30000000000000004 as well.
D lang could have a very good sprintf replacement.
More information about the Digitalmars-d-learn
mailing list