If allowed by your analytics, you could alternatively divide by a very small number:

x= n/MAX(d, 0.001);