[Python-ideas] math.nextafter

M.-A. Lemburg mal at egenix.com
Mon Feb 6 20:44:31 EST 2017


On 07.02.2017 00:46, Steven D'Aprano wrote:
> On Mon, Feb 06, 2017 at 11:29:17AM +0100, M.-A. Lemburg wrote:
> 
>> I'm not sure how useful this would be in the stdlib,
>> since it's very much tied to whatever float type Python
>> happens to use on a platform.
> 
> With the possible exception of µPy, are there any Python implementations 
> which don't use a C double as float?

(I'm not sure what you mean with "µPy")

By far most implementations will use IEEE 754 64-bit doubles:

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

MicroPython also supports single precision float configurations
or no floats at all (depends on the availability of an FPU).

What I wanted to say with the above comment is that Python
itself does not make guarantees on how floats are represented
internally (in CPython it's a C double, which only has
minimum requirements).

In theory, it would be possible to have a Python implementation
using e.g. binary128 floats or MPFR (http://www.mpfr.org/).

You are right in saying that this is a rather unlikely
case :-)

However, using the internal representation of floats to
define a "valid" interval for roots doesn't sound like a
good concept. Those intervals will depend on where the
roots are. Close to 0, the intervals will be very small,
near the outer range limits, very large:

https://blogs.msdn.microsoft.com/dwayneneed/2010/05/06/fun-with-floating-point/

I guess there is some use in trying to determine the
error intervals of calculations, though. Perhaps that's
the main intent of those functions.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Feb 07 2017)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
                      http://www.malemburg.com/



More information about the Python-ideas mailing list