`
daojin
  • 浏览: 676310 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

浮点数的比较

 
阅读更多

a>b   if( (a-b) > EPSINON)
a<b   if( (a-b) <-EPSINON)
a>=b if( (a-b) >= -EPSINON)
a<=b if( (a-b) <=  EPSINON)
a==b if ((a-b>=-EPSINON) && (a-b<=EPSINON))

 

 

#include
// Define your own tolerance

const double EPSILON = 1.00e-07;
const float   FLT_EPSILON  = 1.192092896e-07F;

const double  DBL_EPSILON = 2.2204460492503131e-016;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics