How to calculate percentages

math

I want to calculate what is $x percentage of a $total. $x could be 15%, 20%, etc, and $total could be 1000, 2000, etc. So I'd want the 15% of 1000, for example.

What is the formula for calculating this? (I know this isn't exactly a coding question but I'm coding this feature and need help!

Best Solution

(actual / available) * 100 = percent // start

actual / available = percent / 100

actual = (percent / 100) * available // finish

E.g. 15% of 1000

actual = (15 / 100) * 1000
actual = 0.15 * 1000
actual = 150