# Converting seconds into days, hours, minutes, and seconds

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.

-
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 '14 at 3:11

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.

-