10.0014 + 0.0000123456 = 10.0014?

Hi everyone,

I have a question, for example.
we define real a = 10.0014 and real b = 0.0000123456
then we compute a+b by using FreeFem
we obtain a+b = 10.0014, however the ture is 10.0014123456

so how can we avoid such error during the use of FreeFem. I encounter such error. if t = 10.0014 and dt = 0.0000123456, then the time step cannt be moved into a new time.

I get 10.0014123456.

Hi, thanks for your replying. I run the code, and obtian 10.0012

You are not using a high enough precision for cout.

Hi, thanks a lot.
i define real d = 10.0012 and find that d != c. So when performing operations, you mean the real value of c is 10.0012123456 not 10.0012 ?

Yes, that is correct.

Thanks again for your explanation. I get it and need to consider other direction to correct my code.

Please see Freefem default precision

real a=10.0012;
real b=0.0000123456;
cout << a+b << endl;
cout.precision(16);
cout << a+b << endl;

Hi, thanks for your replying. I get it.