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 working on an assignment for a computer science class, but am having a little trouble. Here is the problem: If we use a modem to transfer files, how long will it take to transfer 1,288,490,188,800 bits at a speed of 3500 bits per second? Assume 5% overhead, i.e., you have to send the number of bits times 1.05. Give answer in Days:Hours:Minutes:Seconds.

Here's what I did:

(1,288,490,188,800/3500)*1.05 = 386,547,056.64 seconds

386,547,056.64 / (60*60*24) = 4473.92 days
Days = 4473.92 = 4473
Hours = .92 * 24 = 22.08 = 22
Minutes = .08 * 60 = 4.8 = 4
Seconds = .8 * 60 = 48
Time at 3500 bps: 4473:22:04:48

I was told the following: "You should be thinking in terms of an integer quotient and a remainder, not a float quotient with a decimal fraction."

How can I fix my solution? I need to do other problems just like this, so please show your work. Thanks for any help.

share|improve this question
    
Your instructor's advice on how to solve the problem (as stated) is correct. The problem statement itself, however, is abominable. –  David K Aug 30 at 3:11

2 Answers 2

up vote 2 down vote accepted

Instead of going from seconds to days then back down to hours/minutes/seconds, just do it in a single pass:

s = 386547057;

// Split s into minutes and seconds.
m       = s / 60; // 6442450 minutes.
seconds = s % 60; // 57 seconds.

// Split m into hours and minutes.
h       = m / 60; // 107374 hours.
minutes = m % 60; // 10 minutes.

// Split h into days and hours.
days    = h / 24; // 4473 days.
hours   = h % 24; // 22 hours.
share|improve this answer

How about this: Let S=seconds M=int(S/60)=minutes H=int(M/60)=hours D=int(H/24)=days

Time required = D days (H-24D) hours (M-60H) minutes (S-60M) seconds

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.