Odd math related issue.
Robert Rawlins
robert.rawlins at thinkbluemedia.co.uk
Mon Jul 21 04:46:51 EDT 2008
Guys,
I've got what seems to me to be a totally illogical math issue here which I
can't figure out. Take a look at the following code:
self.__logger.info("%i / %i" % (bytes_transferred,
self.__sessions[path].total_bytes))
percentage = bytes_transferred / self.__sessions[path].total_bytes *
100
self.__logger.info("%i" % percentage)
Seems fairly straight forward, you would think. It takes two values and
calculates the percentage of one from the other, however, percentage always
comes back as '0' for some reason, look at this log output.
2008-07-21 08:39:05,465 manager.py 78 INFO 290112 / 442435
2008-07-21 08:39:05,466 manager.py 80 INFO 0
Any suggestions as to why this might be the case? I'm sure it's something
dumb but I can't spot it.
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080721/2ab39a62/attachment.html>
More information about the Python-list
mailing list