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