Nine percentage questions, and the formula behind each one
Try it: Online Percentage CalculatorOn this page
"What percent" is several different questions. The percentage calculator puts them on separate cards so a discount is not computed with the change formula. Every card runs in the browser. The examples below use the same expressions as the components, and formatNumber prints integers as integers and otherwise trims to four decimal places.
Input
Output
Input
Output
The formulas, with numbers
What is X percent of Y. (X / 100) * Y.
20 percent of 1500 is (20 / 100) * 1500 = 300. That is also the example string on the card.
X is what percent of Y. (X / Y) * 100.
45 is what percent of 180 is (45 / 180) * 100 = 25. If Y is 0 the card stops, because that is a division by zero.
Percentage change. ((new - original) / original) * 100.
From 80 to 100 is ((100 - 80) / 80) * 100 = 25, and the card text is an increase. From 100 to 80 is a 20 percent decrease, not a 25 percent decrease. The direction uses the original as the base. If the original is 0, the card returns the error "Cannot calculate change when the original value is 0."
Increase Y by X percent. Y * (1 + X / 100).
Increase 90 by 10 percent is 90 * 1.10 = 99.
Decrease Y by X percent. Y * (1 - X / 100).
Decrease 90 by 10 percent is 90 * 0.90 = 81.
Original before an X percent increase, given the final value. final / (1 + X / 100).
A final value of 120 after a 20 percent increase reverses to 120 / 1.2 = 100. The card rejects a percent outside 0 to 100.
Original before an X percent discount, given the sale price. sale / (1 - X / 100).
A sale price of 80 after 20 percent off reverses to 80 / 0.8 = 100. A 100 percent discount would divide by zero, and the card rejects a percent that is not below 100 for this reverse step.
Percent difference. abs(A - B) / ((A + B) / 2) * 100.
Between 50 and 60 the card's own example is 18.18 percent difference. Checking it: the absolute gap is 10, the average is 55, and 10 / 55 * 100 = 18.1818..., which formatNumber trims to 18.1818. The example string on the card says 18.18. Both come from the same ratio. The longer one is what the formatter emits. If both values average to 0, the error is "Cannot calculate difference when both values average to 0."
X percent off Y. Savings are (X / 100) * Y, and you pay Y - savings.
15 percent off 200 is a saving of 30 and a payment of 170. The card text is Save 30 · Pay 170. A percent below 0 or above 100 is rejected with "Invalid percentage. Enter a number between 0 and 100." A full 100 percent off 80 is allowed on this card: save 80, pay 0. That is different from the reverse-discount card, which cannot divide by zero.
A dirham example that is only arithmetic
15 percent off 200 dirhams is the same card as 15 percent off 200 of anything: save 30, pay 170. The calculator does not know that the unit is MAD. It does not fetch a rate. If the 200 was a dollar price and you need dirhams, convert first with the currency converter, then take the percent, and say which rate table you used. Writing the 170 in Arabic words is a third step, on number to words, and that Arabic line is not full grammatical cheque form.
Mistakes
Using the change formula for a discount. From 200 to 170 is a 15 percent decrease, which matches "15 percent off" only because the discount was defined that way. From 170 back to 200 is not a 15 percent increase. It is (30 / 170) * 100, about 17.6471 percent. The reverse cards exist so you do not do that division wrong.
Swapping the percent and the total. X percent of Y is the same product as Y percent of X, because both are (X * Y) / 100. 20 percent of 1500 and 1500 percent of 20 are both 300. The number cannot tell you that you swapped the fields. The card labels are "Percentage (X)" and "Number (Y)."
Reading 18.18 and 18.1818 as two methods. They are one ratio. The example string rounds to two decimals. The result field keeps up to four.
Limits
There is no tax table and no tip suggestion. Add the percent you mean.
Floating point still applies. A result that is not a clean decimal is trimmed for display, not turned into a fraction.
The page will not tell you whether a shop's "up to 70 percent" applied to your item. You type the numbers you have.
Length and weight are the unit converter. Nothing on this page multiplies by 2.54.

