in reply to Re: using Algorithm::Diff for floats
in thread using Algorithm::Diff for floats
i do not employ the int() function for this.
i take the absolute value of the diff and compare to my threshold. if larger than threshold, simply return original string.
otherwise, get an average of the two values and pump it through sprintf, because comparing floats for equality is dangerous; my understanding is that prevents it from being a number and makes a string.
the case of &$keyGen(3.9, "4.0 somehow") eq &$keyGen(4.0, "3.9 somehow")
both calls should return "3.95".
i just need to figure out how to get my sub to access "$b" when the first parameter is "$a" and vice versa.
i think i was originally unclear. is this better?
|
|---|