Floating-Point arithmetic in dlang - Difference to other languages

Jan Hönig hrominium at gmail.com
Tue Dec 3 09:22:49 UTC 2019


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.


More information about the Digitalmars-d-learn mailing list