[Python-ideas] PEP 485: A Function for testing approximate equality
Steven D'Aprano
steve at pearwood.info
Fri Feb 6 06:10:41 CET 2015
On Thu, Feb 05, 2015 at 09:53:49PM -0600, Ron Adam wrote:
> I prefer the weak version myself. Because if you graph the result of True
> values for rel_tolerance=1. You get a graph where all like signed numbers
> are close. A tolerance of .5 gives a graph of the fifty percent of middle
> like signed numbers. And you can think of it as a percentage of the larger
> value. Which tends to be easier than thinking about percent increase.
I'm afraid I don't understand this description.
> Also this recommends using this method.
>
> http://c-faq.com/fp/fpequal.html
You stopped reading too soon:
[quote]
Doug Gwyn suggests using the following ``relative difference'' function.
It returns the relative difference of two real numbers: 0.0 if they are
exactly the same, otherwise the ratio of the difference to the larger of
the two.
[end quote]
Anyone got a copy of Knuth handy and check the reference given above?
Knuth Sec. 4.2.2 pp. 217-8
I'd like to know what he has to say.
--
Steve
More information about the Python-ideas
mailing list