This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2020-01-12.12:33:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578832414.46.0.631511260032.issue39310@roundup.psfhosted.org>
In-reply-to
Content
In bpo-39288, I added math.nextafter(x, y) function. I propose to now add math.ulp() companion function.

Examples from tests of my PR:

    self.assertEqual(math.ulp(1.0), sys.float_info.epsilon)
    self.assertEqual(math.ulp(2.0 ** 52), 1.0)
    self.assertEqual(math.ulp(2.0 ** 53), 2.0)
    self.assertEqual(math.ulp(2.0 ** 64), 4096.0)

Unit in the last place:

* https://en.wikipedia.org/wiki/Unit_in_the_last_place
* Java provides a java.lang.Math.ulp(x) function: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#ulp-double-

In numpy, I found two references to ULP:

* numpy.testing.assert_array_almost_equal_nulp:
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.testing.assert_array_almost_equal_nulp.html

* numpy.testing.assert_array_max_ulp:
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.testing.assert_array_max_ulp.html

Attached PR implements math.ulp(x).
History
Date User Action Args
2020-01-12 12:33:34vstinnersetrecipients: + vstinner
2020-01-12 12:33:34vstinnersetmessageid: <1578832414.46.0.631511260032.issue39310@roundup.psfhosted.org>
2020-01-12 12:33:34vstinnerlinkissue39310 messages
2020-01-12 12:33:33vstinnercreate