[issue22917] Calculating problem

heme report at bugs.python.org
Sun Nov 23 00:03:36 CET 2014


heme added the comment:

Hi SilentGhost 

Thanx for a quick response. 

Sorry to hear that it is not a bug, my old GW basic interpretor from
1988 has no problem with this simple calculation (123.56 - 62.12 =
61.44) but my new Python interpreter cannot give me a correct answer. 

Yes, I know about precision, I have been using C for several years, but
as I am interested in the Raspberry Pi I would like to use Python with
it. 

And as I would use it as a data collector (from instruments), I need
good precision and reliability. 

Is there anything I can do? (exept changing to another language) 

brg 

Henning 

SilentGhost skrev den 22/11/2014 21:33: 

> SilentGhost added the comment:
> 
> Hi Henning,
> 
> this is not a bug. This is to do with how floating point numbers represented in computers. I'd suggest https://en.wikipedia.org/wiki/IEEE_floating_point [1] as a starting point. Briefly, due to binary base that the computers operate on, not every number can be stored/represented precisely. In any case there are plenty of other information online that you can find useful, the easiest solution is to output correctly formatted strings corresponding to your answers.
> 
> Good luck.
> 
> ----------
> nosy: +SilentGhost
> resolution: -> not a bug
> status: open -> closed
> 
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue22917 [2]>
> _______________________________________

Links:
------
[1] https://en.wikipedia.org/wiki/IEEE_floating_point
[2] http://bugs.python.org/issue22917

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22917>
_______________________________________


More information about the Python-bugs-list mailing list