Re: Division in loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 8, 2009 at 16:40, Randi Botse<nightdecoder@xxxxxxxxx> wrote:
> hi all,
Hi,

>
> while (bytes < size) {
:
>
>        progress = (int) ((bytes / size) * 100);
This is an integer division, and because bytes is always smaller than
size will result in 0. You should cast bytes to double, or multiply by
100 first and than divide by size.

Bert
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux