# How to calculate percentage of comment lines in a code?

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?

-

$\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\%$.