Numbers math pct difference
Exactnumbers_math_pct_differenceDeterministic and authoritative — the canonical answer for this input.
Symmetric percent difference |a - b| / ((|a|+|b|)/2). Order-independent, useful for comparing two measurements.
Parameters
anumberrequiredbnumberrequiredCall it
curl -X POST https://api.snipget.ai/v1/numbers/math/pct-difference \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"a":90,"b":110}'Example response
{
"fraction": 0.2,
"display": "20.00%",
"a": 90,
"b": 110
}FAQ
When would I use percent difference instead of percent change?
Use it when neither value is a baseline, you just want to know how far apart two measurements are. It is order-independent, so comparing 90 and 110 gives the same 20% whether you list them in either order.
How is the percentage calculated?
It divides the gap between the two values by their average: the absolute difference of a and b over the mean of their magnitudes. That is what makes it symmetric, unlike percent change which divides by a specific starting value.
Why isn't this the same as percent change?
Percent change needs a before and an after and can be negative. Percent difference treats both inputs as equals and is always zero or positive. Pick change for trends over time and difference for comparing two readings.
Is the answer exact?
Yes, it is deterministic. The same two numbers always return the same authoritative fraction, with a two-decimal display string included.
What if both values are zero?
Percent difference is undefined when both are zero, so you get a result flagged is_valid false with a why_invalid reason and confidence 0, rather than an error.