Avoid NaN results if p is zero