在计算增量/减量百分比时除以零

I am trying to know if a value ($x) is 50% bigger or smaller than a value ($y).

I am doing this:

$diff = ($x - $y) / $x;

if (abs($diff) > 0.5) {

echo "it's happening";
}

The problem is when $x is 0. How can I solve that cleanly? Notice that I want to be able to calculate the increment/decrement even when the value is 0.

If you want to find out ' if a value ($x) is 50% bigger or smaller than a value ($y).', then you should divide the difference by $y instead of $x. And when $y equals to zero, then any value (+ve or -ve) is infinitesimally larger or smaller than $y. No finite calculation is possible there.