Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing C programming exercise for college, and couldn't figure out how to calculate the following value based on four values (2 of each from one type of variable). The exercise is to write a program for a progress bar for downloading a file.

Given values/variables:

  • time: the current time
  • startTime: the download start time
  • bytes: the number of bytes downloaded
  • totalBytes: the total file size in bytes

The program needs to calculate the Elapsed_Time, Percent_Completed, Download_Speed, Total_Time and Remaining_Time.

I can't figure out the formula for Total_Time. That is the estimated total time to download the file.

I used this, but didn't work:

(time - startTime) / (totalBytes - bytes)

Any help is appreciated. Cheers

share|cite|improve this question
up vote 1 down vote accepted

You have spent time-startTime downloading bytes. So you would estimate the rate of download as $\frac {\text{bytes}}{\text{time-startTime}}$. Then the total estimated time is totalBytes divided by this. $\text {Total_Time}=\frac{\text{totalBytes(time-startTime)}}{\text{bytes}}$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.