Home>Article>Backend Development> What does eps mean in c language?
In C language, eps refers to precision. It is mainly used in floating-point number operations, because C language floating-point numbers store approximate values.
#Calculation will cause errors, so generally the calculation is meaningless if it is below a certain value.This threshold is eps, which is the accuracy.
eps is a constant specified in advance in the function program. The default eps = 2^(-52) controls the iteration accuracy, which is equivalent to infinity in calculus. Small value.
In matlab
eps(1/2) = 2^(-53)
eps(1) = 2^(-52)
eps( 2) = 2^(-51)
For example:
#includevoid main(){ long fun(int n); int i; double e=0; double eps=1e-6; //eps表示精度 此处指10的-6次方 for(i=0;1.0/fun(i)>eps;i++) { e+=1.0/fun(i); } printf("e=%lf\n",e); } long fun(int n) //求n!的函数 { if(n==0) return 1; else return n*fun(n-1); }
The above is the detailed content of What does eps mean in c language?. For more information, please follow other related articles on the PHP Chinese website!