Avoid division by zero that would cause NaN/Infinity results.