[Python] Somma da linea di comando

Massimo Capanni massimo.capanni a gmail.com
Lun 12 Nov 2012 21:47:23 CET


Salve a tutti,

utilizzo python 2.7.2 in windows.
Spesso uso l'interprete da shell come calcolatrice e poco fa ho notato un
comportato strano facendo delle somme:

C:\Users\max>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 12.20
>>> b = 9.20
>>> c = 4.20
>>> print a + b + c
25.6
>>>
>>> 12.20 + 9.20 + 4.20
25.599999999999998
>>>

per quale motivo sommando direttamente gli addendi ottengo un risultato non
corretto?
E' un problema dell'interprete secondo voi?

MC
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20121112/445de5af/attachment.html>


Maggiori informazioni sulla lista Python