>>> s = [.1,.1,.1,.1,.1,.1,.1,.1,.1,.1] >>> sum(s) 0.9999999999999999 >>> print(sum(s)) 1.0 Why? >>> f = 0.9999999999999999 >>> f**100 0.9999999999999889 >>> print(f**100) 1.0 Why? >>> f**10000 0.9999999999988898 >>> print(f**10000) 0.999999999999 >>> from math import fsum >>> fsum(s) 1.0 >>> from math import fsum >>> fsum(s) 1.0 See < http://docs.python.org/py3k/library/math.html?highlight=fsum#math.fsum>
The "Why?"s mark what are puzzles for me. I see nothing in the doc for print() that explains these: < http://docs.python.org/py3k/library/functions.html?highlight=print#print>, but I'm sure a Tutor can. Dick Moores
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
