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.
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 ?
In relation to this question, here is a way to check the internal precision used by FF on any platform
// integer size
// ------------
int i=1;
int n=1;
// Stop when the value is so big that it overflows into the sign bit
while(i>0){
i*=2;
n++;
}
cout<<"int size: "<<n<<endl;
// number of decimal places
// ------------------------
real e=1.;
real sum=1.+e;
n=0;
// Stop when the increment is so small that the sum does not change
while(sum!=1.){
n++;
e=e/10.;
sum=1.+e;
}
cout<<"decimal digits: "<<n<<endl;
// maximum power of 10 in a floating-point number
// ----------------------------------------------
real a=1;
n=0;
// a becomes inf when the exponent is too big, so the test becomes inf==inf
while(a*10!=a){
a*=10;
n++;
}
cout<<"max exponent: "<<n-1<<endl;