Calculate percentage of time

266 Views Asked by At

I currently need to find the percentage of a song (for my program), I have tried doing it the normal way of (current position)/(total length of song), however since seconds go up to 60 and not 100 this does not work. How would I do this with seconds? Both the current position and length of song are in seconds.

To be more clear, how would I work out the percentage of the song, knowing that I am currently 122.277seconds the way through a song that is total of 177320seconds.

Thanks

2

There are 2 best solutions below

5
On BEST ANSWER

You can do this in the usual way, as long as both current position and total length of the song are in the same units (e.g. seconds or minutes or hours, etc). In your example it would be $$ \frac{122.277}{177320} \approx 0.0689 \% $$

(You must have a really long song, $177320$ seconds is about 50 hours, you sure you got the right units?)

0
On

Like gt6989b said, if you're just working in seconds there is no problem and you can just use the convensional way. This is the easy way.

But let's say you are currently at $1'20"$ from a $3'35"$ song you can either calculate it back to seconds or calculate it in minutes, but recalibrate the second part to an accaptable comma value.

$$20 seconds = (20 \times \frac{5}{3})minutes = 0.33 minutes$$

so $1'20" = 1.33$ minutes

$$35 seconds = (35 \times \frac{5}{3})minutes = 0.58 minutes$$

so $3'35" = 3.58$ minutes

The percentage calculated with minutes $=\frac{1.33}{3.58}=0.371$