How to compare double numbers?
I know that when I would like to check if double == double I should write: bool AreSame(double a, double b) { return fabs(a - b) < EPSILON; } But what when I would like to check if a > b or b > a ? There is no general solution for comparing floating-point numbers that contain errors from previous operations. The code that must be used is application-specific. So, to get a proper answer, you must describe your situation more specifically. For example, if you are sorting numbers in a list or other data structure, you should not use any tolerance for comparison. Usually, if your program needs to