Floating point roundoff on Windows

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Floating point roundoff on Windows

lswaenen
Dear all,

If I run the following code as 
python main.py

main.py:
import numpy as np

a = 0.999999999999999888977697537484
print("%.30f" % a)
print("%.30f" % np.sqrt(a))

The output is:
0.999999999999999888977697537484
0.999999999999999888977697537484

However, after feeding it through pyinstaller (Windows 7, 32 bit) and running the executable, the output is
0.999999999999999888977697537484
1.000000000000000000000000000000


On Ubuntu 64-bit, the python output and executable output are both
0.999999999999999888977697537484
0.999999999999999888977697537484

Doesn't seem to matter whether I use numpy or 'import math' 

Does anyone have any idea about this?

Kind regards,
Lense

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Floating point roundoff on Windows

Hartmut Goebel
Am 02.09.2016 um 12:23 schrieb [hidden email]:
Does anyone have any idea about this?

I can't see how is this related to PyInstaller. Please ask the numpy guys.

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/ehrlichkeit-made-in-germany
Kolumne: http://www.cissp-gefluester.de/2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Floating point roundoff on Windows

lswaenen
If you read the whole post, you will see that the bug is also present when importing math instead of numpy.
So
main.py:
import math

a = 0.999999999999999888977697537484
print("%.30f" % a)
print("%.30f" % math.sqrt(a))

gives the exact same outputs.
In that respect, it has everything to do with PyInstaller. And nothing with NumPy.



Op maandag 5 september 2016 15:36:57 UTC+2 schreef Hartmut Goebel:
Am 02.09.2016 um 12:23 schrieb <a href="javascript:" target="_blank" gdf-obfuscated-mailto="uOvdxnVHAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lswa...@...:
Does anyone have any idea about this?

I can't see how is this related to PyInstaller. Please ask the numpy guys.

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
<a style="color:black" href="http://www.goebel-consult.de" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.goebel-consult.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHs4zUB0fQIL_Yg4brDiF83WXvPcg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.goebel-consult.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHs4zUB0fQIL_Yg4brDiF83WXvPcg&#39;;return true;">http://www.goebel-consult.de

Blog: <a style="color:grey!important;text-decoration:none!important" href="http://www.goebel-consult.de/blog/ehrlichkeit-made-in-germany" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.goebel-consult.de%2Fblog%2Fehrlichkeit-made-in-germany\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0NARk-2720bU5eRAABNzNSDhuZQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.goebel-consult.de%2Fblog%2Fehrlichkeit-made-in-germany\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0NARk-2720bU5eRAABNzNSDhuZQ&#39;;return true;">http://www.goebel-consult.de/blog/ehrlichkeit-made-in-germany
Kolumne: <a style="color:grey!important;text-decoration:none!important" href="http://www.cissp-gefluester.de/2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.cissp-gefluester.de%2F2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG9rvedNwJv9PdzDFK822GPgixACg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.cissp-gefluester.de%2F2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG9rvedNwJv9PdzDFK822GPgixACg&#39;;return true;">http://www.cissp-gefluester.de/2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.
Loading...