[Python-ideas] PEP 485: A Function for testing approximate equality

Nathaniel Smith njs at pobox.com
Fri Jan 23 22:40:48 CET 2015


On Fri, Jan 23, 2015 at 5:41 PM, Guido van Rossum <guido at python.org> wrote:
> Isn't an ulp just a base-2 way of specifying precision scaled so that 1 ulp
> is the low bit of the mantissa in IEEE fp?

Basically yes, but there are weird subtleties. E.g. 1 ulp remains the
same absolute size between 1.0 and 2.0, so the same ulp threshold can
vary by a factor of two in relative precision terms. And where you hit
the boundary between exponents funny things happen: 2.0 +/- 1 ulp is
[2.0 - 2.2e-16, 2.0 + 4.4e-16]. This can matter if you're looking for
high precision -- if the value is supposed to be almost 2.0, then you
don't want to get penalized for failing to get 2.0 + 2.2e-16, b/c
there is no such number, but it might also be unacceptable to get 2 -
4.4e-16, which would be two values off.

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org


More information about the Python-ideas mailing list