Is this normal or a bug ?
claptrap
clap at trap.com
Mon Jul 3 09:19:42 UTC 2023
On Monday, 3 July 2023 at 08:24:22 UTC, Mehdi wrote:
> Hello, d community! I am currently exploring the possibilities
> of interoperability between C++ and D. While conducting some
> tests, I came across an interesting case. Here is the C++ code
import std.stdio;
void main()
{
writefln ("%.15f", 10.1 + 20.6);
writefln ("%.15f", 10.1f + 20.6f);
}
prints this...
30.699999999999999
30.700000762939453
the problem is..
assert(10.1 + 20.6 == float_test(10.1, 20.6));
10.1 + 20.6 is done with double (or maybe extended on DMD)
precision
float_test(10.1, 20.6) is done with float precision
More information about the Digitalmars-d
mailing list