I am attempting to make an adaptive 'about equal' method (written in C# but the question is general) accepting two doubles and returning a boolean if they are 'about equal' or not. By adaptive, I mean that:
1.234 and 1.235 ==> TRUE
BUT
1.234567 and 1.234599 ==> FALSE
That is, the precission of 'about equal' adapts to the precission of the numbers.
I found a concept of rounding at How do I find if two variables are approximately equals? but there is still the open ended question of what to use for epsilon.
Is anyone aware of best practices for this sort of problem? Thanks in advance!
EDIT: My initial question did not contain enough information as to what I was trying to get. Sorry about that and my apologies. I want a program that would treat higher precission numbers to a higher standard while being more lenient with lower precission numbers. More examples of pairs would be (where '(0)' is an implied zero):
1.077 and 1.07(0) returns false (because 77 is very different from 70)
1.000077 and 1.00007(0) returns false (because 77 is very different from 70)
1.071 and 1.07(0) returns true (because 71 is close to 70
1.000071 and 1.00007(0) returns true (because 71 is close to 70)
Regardless of the implementing code, I assume there will be a 'tolerance' variable of some sort to determine what is 'very different' and what is 'close'.