On Jul 21, 3:52 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Robert Rawlins wrote:
> > 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,
> > /sel
sahasranaman wrote:
Use 2.0 / 3 * 100 to solve this. Why make things look bigger?
you mean that
a.0 / 3 * 100
works in your Python version? that's interesting.
(maybe you should at least skim the the thread before you jump in?)
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 21, 5:30 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Alexandru Palade wrote:
> > However, you should be carefully because using an %i modifier for a
> > what-should-be a float value truncates the value in a way you may not
> > expect.
>
> > What I mean is that if you have sent 2 out of 3
On Jul 21, 5:30 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Alexandru Palade wrote:
> > However, you should be carefully because using an %i modifier for a
> > what-should-be a float value truncates the value in a way you may not
> > expect.
>
> > What I mean is that if you have sent 2 out of 3
On Jul 21, 10:21 pm, Alexandru Palade
<[EMAIL PROTECTED]> 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 t
Alexandru Palade wrote:
However, you should be carefully because using an %i modifier for a
what-should-be a float value truncates the value in a way you may not
expect.
What I mean is that if you have sent 2 out of 3 bytes, the math will be
200/3 which with the %i modifier will print 66, rathe
However, you should be carefully because using an %i modifier for a
what-should-be a float value truncates the value in a way you may not
expect.
What I mean is that if you have sent 2 out of 3 bytes, the math will be
200/3 which with the %i modifier will print 66, rather than 66.6 (or at
least 6
> if you divide two integers, you'll get an integer back (in Python 2.X,
> at least). quick fix:
>
> percentage = bytes_transferred * 100 / total_bytes
>
>
Hey
That worked a charm mate, thanks for the info.
--
http://mail.python.org/mailman/listinfo/python-list
Robert Rawlins wrote:
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