Re: Division in loop

Bert Wesarg <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
On Tue, Sep 8, 2009 at 16:40, Randi Botse<[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.