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 <>
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:

* Java provides a java.lang.Math.ulp(x) function:

In numpy, I found two references to ULP:

* numpy.testing.assert_array_almost_equal_nulp:

* numpy.testing.assert_array_max_ulp:

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