C で 2 つの double 型の変数を比較するために、 を定義し#define EQUALITY_EPSILON = 1e-8
ました。私は次のように比較を行っています:
if((img_score[i] - img_score[j]) >= EQUALITY_EPSILON){
// handle for ith score greater than jth score
}
else if((img_score[j] - img_score[i]) >= EQUALITY_EPSILON){
// handle for ith score smaller than jth score
}
else{
// handle for ith score equal to jth score
}
私が直面している問題は、コード内のスコアが非常に小さいためEQUALITY_EPSILON = 1e-8
、 の場合、比較の結果が等しい場合があることです。私の質問は、どのくらい小さく設定できEQUALITY_EPSILON
ますか?