Floating-Point arithmetic in dlang - Difference to other languages

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue Dec 3 11:08:33 UTC 2019


On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
> not evaluate into: 0.30000000000000004, like C++
> but rather to: 0.29999999999999999

You get the same in C++ with:

#include <cstdio>
int main()
{
     printf("%.17f",double(0.1L + 0.2L));
}


More information about the Digitalmars-d-learn mailing list