results of division

Peter Hansen peter at
Thu Dec 9 18:02:21 CET 2004

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.


More information about the Python-list mailing list