Home >Backend Development >C#.Net Tutorial >What does 1e-6 mean in C language?

What does 1e-6 mean in C language?

coldplay.xixi
coldplay.xixiOriginal
2020-08-19 15:42:5636831browse

c语言中1e-6的意思是:1、【1e-6】表示1乘以10的负6次方;2、【1e-6】叫做epslon,用来抵消浮点运算中因为误差造成的相等无法判断的情况,它通常是一个非常小的数字。

What does 1e-6 mean in C language?

c语言中1e-6的意思是:

1e-6表示1乘以10的负6次方。

Math.abs(x)<1e-6其实相当于x==0

1e-6(也就是0.000001)叫做epslon,用来抵消浮点运算中因为误差造成的相等无法判断的情况。它通常是一个非常小的数字(具体多小要看你的运算误差)

比如说因为精度误差,用十进制举例,我们要算1/3+1/3+1/3==1(从数学上说,肯定相等),但是因为精度问题,等号左边算出来是0.3333333+0.3333333+0.3333333=0.9999999,

存在了误差,右边是1.0000000,那么如果直接用==,返回false,我们希望它被视作相等。那么就要两数相减取绝对值小于epslon的办法。

相关学习推荐:C视频教程

The above is the detailed content of What does 1e-6 mean in C language?. For more information, please follow other related articles on the PHP Chinese website!

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