[Python-ideas] PEP 485: A Function for testing approximate equality (original) (raw)
Paul Moore p.f.moore at gmail.com
Fri Feb 6 14:35:43 CET 2015
- Previous message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Next message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6 February 2015 at 12:28, Antoine Pitrou <solipsis at pitrou.net> wrote:
Ok, more simply then: does iscloseto(0.0, 0.0) return True?
From the formula in the PEP
"""abs(a-b) <= max( rel_tolerance * min(abs(a), abs(b), abs_tolerance )"""
yes it does. More generally, is_close_to(x, x) is always true. That's a key requirement - that "closeness" includes equality.
I think the "weirdness" around zero is simply that there's no x for which is_close_to(x, 0) and x != 0. Which TBH isn't really all that weird :-)
FWIW, I'm +0.5 with the PEP. (It lost a 0.5 for no other reason than I don't actually have a use for the function, so it's mostly theoretical interest for me).
Paul
- Previous message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Next message: [Python-ideas] PEP 485: A Function for testing approximate equality
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]