Home > Backend Development > C#.Net Tutorial > What does eps mean in c language?

What does eps mean in c language?

little bottle
Release: 2019-05-27 13:32:36
Original
23210 people have browsed it

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.

What does eps mean in c language?

#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:

#include<stdio.h>
void 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);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template