Skip to content

JavaScript8 min read

How to Calculate Percentage: Formulas With Examples

How to calculate a percentage of a number, percentage change, reverse percentages, discounts and VAT, with simple formulas, worked examples and a free tool.

To calculate a percentage, divide the part by the whole and multiply by 100: 45 out of 180 is 45 ÷ 180 × 100 = 25%. To find a percentage of a number, go the other way: 15% of 250 is 15 ÷ 100 × 250 = 37.5. Almost every other percentage question (change, discount, VAT, reverse percentage) is one of these two formulas rearranged, and my free percentage calculator shows each one with the working filled in.

I build calculators and pricing screens for a living, and the bugs I have fixed in them are rarely about hard maths. They come from using the wrong base number, adding percentages that should be multiplied, or rounding too early. This guide covers the formulas and those traps.

Key takeaways

  • Percentage = part ÷ whole × 100. X% of Y = X ÷ 100 × Y.
  • Percentage change = (new − old) ÷ old × 100. Always divide by the starting value.
  • Reverse a percentage by dividing, not subtracting: the price before 13% VAT is total ÷ 1.13.
  • Stacked percentages multiply. Two 10% rises are 21%, and 20% off then 10% off is 28% off.
  • A drop of 50% needs a rise of 100% to recover. Percentage changes are not symmetric.
  • "Percentage points" and "percent" are different units. Say which one you mean.

The six formulas you will actually use

Question Formula Example
What is X% of Y? X ÷ 100 × Y 15% of 250 = 37.5
X is what % of Y? X ÷ Y × 100 45 of 180 = 25%
% change from A to B (B − A) ÷ A × 100 80 → 120 = +50%
Add X% to Y Y × (1 + X ÷ 100) 1,000 + 13% = 1,130
Take X% off Y Y × (1 − X ÷ 100) 2,000 − 25% = 1,500
Original value before X% change Result ÷ (1 ± X ÷ 100) 75 after 25% off = 100

The first four rows are the four panels of the percentage calculator: it computes the answer as you type and prints the exact formula it used, so you can check it or copy it into a report.

How to find a percentage of a number

Turn the percentage into a decimal by dividing by 100, then multiply. 15% becomes 0.15, and 0.15 × 250 = 37.5.

A handy mental shortcut: X% of Y is the same as Y% of X. 8% of 50 sounds awkward, but 50% of 8 is obviously 4. It works because both are X × Y ÷ 100.

For quick estimates, find 10% by moving the decimal point one place left, then scale. 10% of 4,600 is 460, so 5% is 230 and 15% is 690.

How to work out what percentage one number is of another

Divide the part by the whole, then multiply by 100. If you scored 68 out of 80 in a test, 68 ÷ 80 = 0.85, so you got 85%.

The only thing that goes wrong here is picking the wrong "whole". If 12 people out of a team of 40 are remote, the share is 12 ÷ 40 = 30%. It is not 12 ÷ 28 (the office staff), which answers a different question: "how many remote people are there for every office person?"

Percentage increase and decrease

Subtract the old value from the new one, divide by the old value, and multiply by 100.

  • Rent goes from 20,000 to 23,000: (23,000 − 20,000) ÷ 20,000 × 100 = 15% increase.
  • A share price falls from 500 to 400: (400 − 500) ÷ 500 × 100 = −20%, a 20% decrease.

Why percentage changes do not cancel out

If something falls 20% and then rises 20%, you do not get back to where you started. 500 falls to 400, and 20% of 400 is only 80, so you end at 480. The base changed in between.

The bigger the fall, the bigger the gap. After a 50% drop you need a 100% rise to recover, because half of the original is now your starting point. I find this is the single most useful fact for reading investment returns and traffic charts.

Percent vs percentage points

When the thing you are measuring is already a percentage, there are two ways to describe a change:

  • An interest rate moving from 10% to 15% has risen by 5 percentage points.
  • Relative to where it started, it has risen by 50 percent (5 ÷ 10 × 100).

Both statements are true, and mixing them up is one of the most common mistakes in news and business reports. When the starting value is small, write both so nobody misreads the size of the change.

Reverse percentages: finding the original value

This is where most people go wrong. If a jacket costs 1,500 after 25% off, the original price is not 1,500 + 25% (1,875). The 25% was taken from the original, not from 1,500.

The right way is to divide by what is left:

  • After 25% off, 75% remains. 1,500 ÷ 0.75 = 2,000.
  • After a 10% raise, you have 110%. A salary of 66,000 was 66,000 ÷ 1.10 = 60,000 before the raise.

The fourth panel of the calculator, "Original value before discount", does exactly this division.

Discounts, VAT and other stacked percentages

Adding and removing VAT

In Nepal the standard VAT rate is 13%, which is the rate my invoice generator uses by default. To add it, multiply by 1.13. To find the price before VAT from a VAT-inclusive total, divide by 1.13:

  • 10,000 + 13% VAT = 10,000 × 1.13 = 11,300.
  • A bill of 11,300 including VAT was 11,300 ÷ 1.13 = 10,000 before VAT, so the VAT part is 1,300.

Subtracting 13% from 11,300 gives 9,831, which is wrong. That is the reverse percentage trap again.

Two discounts in a row

Shops love "20% off, plus an extra 10% at checkout". The second discount applies to the already reduced price:

  1. 100 − 20% = 80
  2. 80 − 10% = 72

You pay 72, so the real discount is 28%, not 30%. In one step: 100 × 0.80 × 0.90 = 72. Stacked percentages always multiply.

Growth over several years

The same rule explains compound growth. A salary that rises 10% a year for two years grows by 1.10 × 1.10 = 1.21, which is 21%, not 20%. If you want the yearly loan side of this, I wrote a separate guide on EMI and salary tax calculations.

Percentages in Excel and Google Sheets

Spreadsheets store 15% as the number 0.15 and only display it with a percent sign. That is why =A1*B1 works when B1 is formatted as a percentage.

Text
Percentage of a number:     =B2*C2            (C2 holds 15%)
What % is A of B:           =A2/B2            then format the cell as %
Percentage change:          =(B2-A2)/A2       then format the cell as %
Add VAT:                    =A2*(1+13%)
Price before VAT:           =A2/(1+13%)

If a result shows 2500% instead of 25%, the formula already multiplied by 100 and the % format multiplied again. Remove the *100.

Getting percentages right in JavaScript

Since most of my work is front-end code, here is what I check whenever a percentage reaches the UI.

JavaScript
const pct = (part, whole) => (whole === 0 ? null : (part / whole) * 100);
const change = (from, to) => (from === 0 ? null : ((to - from) / from) * 100);

// Format for display only at the very end
const fmt = new Intl.NumberFormat('en-US', { style: 'percent', maximumFractionDigits: 1 });
fmt.format(0.256);            // "25.6%"  (percent style expects a fraction, not 25.6)
fmt.format(pct(45, 180) / 100); // "25%"

Three habits save most of the bugs:

  1. Guard division by zero. A change from 0 has no meaningful percentage. Show "n/a" rather than Infinity%.
  2. Round once, at the end. Floating point means 0.1 + 0.2 is 0.30000000000000004. Rounding intermediate values makes totals drift, so keep full precision and format only for display.
  3. Remember style: 'percent' multiplies by 100. Pass 0.25, not 25. The MDN page for Intl.NumberFormat lists the options.

Common mistakes to avoid

  • Dividing by the new value in a percentage change. Always divide by the starting value.
  • Subtracting a percentage to reverse it. Divide instead.
  • Adding stacked percentages. Multiply the factors.
  • Averaging percentages from groups of different sizes. 50% of 10 people and 10% of 1,000 people is not an average of 30%. Add the parts and the wholes first: 105 ÷ 1,010 ≈ 10.4%.
  • Calling a percentage point change a percent change. They are different units.

FAQ

What is the basic formula to calculate a percentage?

Divide the part by the whole and multiply by 100. For example, 45 out of 180 is 45 ÷ 180 × 100 = 25%.

How do I find X percent of a number?

Divide the percentage by 100 and multiply by the number. 15% of 250 is 15 ÷ 100 × 250 = 37.5.

How do I calculate percentage increase or decrease?

Subtract the old value from the new value, divide by the old value and multiply by 100. Going from 80 to 120 is (120 − 80) ÷ 80 × 100 = 50% increase. A negative result is a decrease.

How do I find the original price before a discount?

Divide the sale price by (1 − discount ÷ 100). A price of 75 after 25% off was 75 ÷ 0.75 = 100 before the discount.

What is the difference between percent and percentage points?

Percentage points are the plain gap between two percentages. Percent change is that gap relative to where you started. A rate moving from 10% to 15% rose 5 percentage points, which is a 50% increase.

Why don't two discounts of 20% and 10% add up to 30%?

The second discount applies to the already reduced price. 100 becomes 80 after 20% off, then 72 after 10% off, so the total discount is 28%, not 30%.

Wrapping up

Two formulas do almost all the work: part ÷ whole × 100, and X ÷ 100 × Y. The mistakes come from the base: divide changes by the starting value, reverse a percentage by dividing, and multiply stacked percentages instead of adding them. When you want the answer and the working without doing it by hand, open the free percentage, age and date calculator. It runs in your browser, shows every formula, and also counts exact ages and working days between dates.

  • #math
  • #percentage
  • #calculator
  • #javascript
  • #excel
  • #tools

Web7 min read

Merge, Split and Compress PDFs Without Uploading

How to merge, split, compress, rotate and convert PDFs for free without uploading them, why it matters for private documents, and how browser-only tools work.

Read article