2012/11/12 Massimo Capanni <massimo.capa...@gmail.com>: > 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?
Curioso. Il mio python, 2.7.3 su linux, ha il comportamento diametralmente opposto. miron@aspie:~$ python Python 2.7.3 (default, Aug 1 2012, 05:16:07) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 12.20 >>> b = 9.20 >>> c = 4.20 >>> a + b + c 25.599999999999998 >>> print 12.20 + 9.20 + 4.20 25.6 >>> PS: <http://docs.python.it/html/tut/node15.html> > MC © -- R K-<M>-S L _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python