I need to compare to double variables like this
if (distance <= radius)
both distance and radius are doubles and I remember in class how to use epsilon comparisons for checking equality but how would I do it for <= or >?
3
An epsilon is not relevant when you are checking which floating point value is bigger. It’s only needed for equality, where (due to precision issues) your math may create two values which are supposed to be equal, but are slightly off.
4
It depends on your definition of “<=”.
If you want to declare them equal if they are within a certain distance of each other, then you would do:
if ((a < (b+epsilon)) do_whatever();
This is counterintuitive, since it would accept a > b by less than epsilon, which is probably not what you want. But it might be.
In general, talking about floating-point (which includes doubles) equality is meaningless.