Price Comparison Calculator Formula
Understand the math behind the price comparison calculator. Each variable explained with a worked example.
Formulas Used
Product A Unit Price
unit_price_a = unit_aProduct B Unit Price
unit_price_b = unit_bPrice Difference
pct_difference = abs(unit_a - unit_b) / max(unit_a, unit_b) * 100Variables
| Variable | Description | Default |
|---|---|---|
price_a | Product A Price(USD) | 3.99 |
qty_a | Product A Quantity | 6 |
price_b | Product B Price(USD) | 5.49 |
qty_b | Product B Quantity | 10 |
unit_a | Derived value= price_a / qty_a | calculated |
unit_b | Derived value= price_b / qty_b | calculated |
How It Works
How to Compare Product Prices
Compute the unit price for each product, then see which is lower. The percentage difference tells you how much more expensive the pricier option is.
Formula
Unit Price = Total Price / Quantity
Difference % = |Unit A - Unit B| / max(Unit A, Unit B) x 100
Worked Example
Product A: 6-pack for $3.99 vs Product B: 10-pack for $5.49.
price_a = 3.99qty_a = 6price_b = 5.49qty_b = 10
- 01Product A unit price = $3.99 / 6 = $0.6650
- 02Product B unit price = $5.49 / 10 = $0.5490
- 03Product B is cheaper per unit
- 04Difference = |$0.6650 - $0.5490| / $0.6650 x 100 = 17.4%
Ready to run the numbers?
Open Price Comparison Calculator