results of division
aahz at pythoncraft.com
Fri Dec 10 01:52:16 CET 2004
In article <cpa0dq$i10$1 at utornnr1pp.grouptelecom.net>,
Peter Hansen <peter at engcorp.com> wrote:
>Brad Tilley wrote:
>> Peter Hansen wrote:
>>> The answer is "what are you trying to do?". The others have
>>> given options and good advice, but the "right" approach
>>> depends on what exactly you are doing. Is this just for
>>> display purposes, or is there more significant (though
>>> perhaps not "precision-critical") calculation going on?
>> I'm summing up the bytes in use on a hard disk drive and generating a
>> report that's emailed based on the percentage of the drive in use. I
>> know there are other ways to do this, but I like Python and I like to
>> write my own code. I always find comp.lang.python a very helpful place.
>So, from the sounds of it, you really care about this
>rounding operation in the displayed values, in which
>case the "'%.2f' % value" approach ought to be fine.
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"19. A language that doesn't affect the way you think about programming,
is not worth knowing." --Alan Perlis
More information about the Python-list