Terry said unto the world upon 06/28/2007 02:55 PM: > I am going to need to be handling money calculations and was wondering > about the float problem > in my calculations. > > Should I simply run the results of all calculations through something > like this: > > from __future__ import division > ... > ... > s=(int(round(s, 2)*100))/100 > > Or should I be using Decimal on all money calculations? > > Or, is there another more preferred approach?
Hi Terry, I'd say definitely use Decimal. Money calculations were a primary use case for the Decimal module. (Though a bit more needs to be done to get the right decimal precision. See <http://www.python.org/dev/peps/pep-0327/>.) Best, Brian vdB _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor