Implementing a range is the "correct" way to do it, but not the only way. Another option is to cast the double value to an int, or using Math.round(distance). This would strip the trailing decimal places on the double.
Both
Code:
int compare_distance = (int)distance;
if(compare_distance != 6){
//Covers values from 6.0 to 6.999...
}
and
Code:
if(Math.round(distance) != 6){
//Covers values from 5.5 to 6.4999...
}
will work equally well in most cases.