To compare two double type variables in C, I have defined #define EQUALITY_EPSILON = 1e-8
. I am doing the comparison as follows:
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
}
The problem I am facing is that the scores in my code are extremely small, therefore for EQUALITY_EPSILON = 1e-8
, the result of comparison turns out to be equality in some cases. My question is how small can I set EQUALITY_EPSILON
?