
Percentages
Calculate a percentage, a share or a change between two values.
Your inputs stay in your browser. Displayed results are rounded to a maximum of 12 significant digits.
Method and assumptions
Method version 1.0.0 · Updated
Percentage of a value
Formula: value × rate ÷ 100
Example: 20% of 150 = 30.
- rate
- Percentage (%)
- value
- Reference value
Share as a percentage
Formula: part ÷ total × 100
Example: 30 out of a total of 150 is 20%. The total must be positive.
- part
- Part
- total
- Total
Percentage change
Formula: (next − previous) ÷ previous × 100
Example: going from 80 to 100 is a +25% change. A decrease gives a negative result. The initial value must be positive.
- previous
- Initial value
- next
- Final value
Deterministic floating-point calculation. The displayed result is rounded to a maximum of 12 significant digits.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const percentOf = 200 * 12 / 100; // 24
const ratioPercent = 18 / 72 * 100; // 25
const changePercent = (100 - 80) / 80 * 100; // 25 increase
console.log(percentOf, ratioPercent, changePercent);TypeScript
const percentOf: number = 200 * 12 / 100; // 24
const ratioPercent: number = 18 / 72 * 100; // 25
const changePercent: number = (100 - 80) / 80 * 100; // 25 increase
console.log(percentOf, ratioPercent, changePercent);Python
percent_of = 200 * 12 / 100 # 24
ratio_percent = 18 / 72 * 100 # 25
change_percent = (100 - 80) / 80 * 100 # 25 increase
print(percent_of, ratio_percent, change_percent)Java
double percentOf = 200 * 12 / 100.0; // 24
double ratioPercent = 18 / 72.0 * 100; // 25
double changePercent = (100 - 80) / 80.0 * 100; // 25 increase
System.out.println(percentOf + " " + ratioPercent + " " + changePercent);C#
double percentOf = 200 * 12 / 100.0; // 24
double ratioPercent = 18 / 72.0 * 100; // 25
double changePercent = (100 - 80) / 80.0 * 100; // 25 increase
Console.WriteLine($"{percentOf} {ratioPercent} {changePercent}");