[SciPy-Dev] Floating point differences in CPython

Juan Luis Cano juanlu001 at gmail.com
Mon Dec 2 02:05:39 EST 2019


Hi all,

I admit this is not strictly about SciPy, but there is lots of people in
this list that care about compilers and floating point math so I still
wanted to give it a try.

I am observing floating point differences between two different versions of
CPython 3.7.5, one compiled with GCC 7.4.0 (latest Linux Mint) and other
compared with GCC 8.3.0 (Debian Buster) that can be reproduced like this:

$ docker run --rm -it python:3.7.5-stretch python -c
'print("{:.10f}".format((7091.17117297555159893818 ** 2 +
7118.70008070942458289210 ** 2 + (-1513.67274389594149397453) ** 2) **
1.5))'
1049171479739.7584228516
$ docker run --rm -it python:3.7.5-buster  python -c
'print("{:.10f}".format((7091.17117297555159893818 ** 2 +
7118.70008070942458289210 ** 2 + (-1513.67274389594149397453) ** 2) **
1.5))'
1049171479739.7585449219


I highlight the GCC version because as far as I understand is the only
thing that could have changed between the two. Does anybody have a more
detailed explanation of what's going on here?

Best,

-- 
Juan Luis Cano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20191202/7be4e781/attachment.html>


More information about the SciPy-Dev mailing list