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 have a file within which I have 6 lines of code and 8 lines of comment.

What's the formula to calculate how much percent of the whole file comments have?

share|improve this question
@downvoter: care to explain? This is very much on-topic, asking a clear mathematical question. –  Srivatsan Jan 4 '12 at 16:12
add comment

1 Answer

up vote 4 down vote accepted

Percentage is a ratio of the part you want to the whole.

$\dfrac{\text{Number of lines of comment}}{\text{Total number of lines of the file}} = \text{Percent}$

In order to transform this into a more recognizable percentage, as opposed to a decimal, multiply by $100$. For instance, $0.75$ corresponds to $75\%$.

I highly recommend that you spend some time on proportions and fractions, as I consider these important skills in day-to-day life.

share|improve this answer
This might be obvious to you and me, but it might well be the case that the OP is confused whether to multiply or divide by the mysterious $100$. ("Should it go in the top or the bottom of this fraction?") Perhaps you could include that bit as well? :-) –  Srivatsan Jan 4 '12 at 16:16
Good idea. ${}{}{}$ –  mixedmath Jan 4 '12 at 16:29
@mixedmath thank you. –  smallB Jan 4 '12 at 16:35
add comment

Your Answer


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.