Odd math related issue.
sjmachin at lexicon.net
Mon Jul 21 14:36:39 CEST 2008
On Jul 21, 10:21 pm, Alexandru Palade
<alexandru.pal... at sellerengine.com> wrote:
> Another thing, you could have just added a dot after the constant in
> order to promote the expression to be evaluated as float. As in
> percentage = bytes_transferred / /self/.__sessions[path].total_bytes
> * 100.
> (notice the last dot)
True, you get a float result, but not a very useful one:
>>> a = 2
>>> b = 11
>>> a / b * 100 # OP's problem
>>> a / b * 100. # Your suggestion; same as (a / b) *100.
>>> a * 100 / b # Fredrik's suggestion
>>> a * 100. / b # What you probably meant
More information about the Python-list