Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question

1 Answer 1

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|improve this answer

Your Answer

 
discard

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.