标签: c++ std equality floating-accuracy
更确切地说,std::equal_to<float>()(float a,float b)或std::equal_to<double>()(double a,double b)是否会像abs(diff) < EPSILON或a==b更好地实现浮动等式?
std::equal_to<float>()(float a,float b)
std::equal_to<double>()(double a,double b)
abs(diff) < EPSILON
a==b
答案 0 :(得分:7)
std::equal_to使用==执行比较。如果你想与公差进行比较,你必须自己写。 (或使用图书馆。)
std::equal_to
==