Home > Blockchain >  Percetange calculation wrong result
Percetange calculation wrong result

Time:08-09

I want to calculate the percentage of a minute from a given number of hours. So let's say I have 2 hours. That's 2*60 minutes. And I want to know how much percent does 1 minute take from 2 hours. The value should be 0.833, because 0.833 * (2*60) = 100%. But how do I get this 0.833 number?

(hours * 60) / 100 gets me 1.2 when hours=2, not 0.833

It's a simple question I know, but I just cannot figure out why my percentage is not right.

CodePudding user response:

The formula should be 1 minute / total minutes. So for 2 hrs, its 1 min / 120 min = 0.00833 which is 0.833%.

CodePudding user response:

You made a simple algebra mistake. If you carefully re-write your fraction, you will see that this one is incorrect:

(hours * 60) / 100

The relation you are looking for is actually:

100 / (hours * 60)

Indeed, 1 / 1.2 = 0.833

CodePudding user response:

Your formula should look like this :

percentage = (minutes/totalMinutes)*100

  • Related