However, this does not avoid the divide by zero error because all of the arguments to the if function are evaluated.
I could change it to a Javascript field, but I prefer the simplicity of the calculation fields.
A work-around involves nested if functions: (the interior if forces the denominator to be 1 in the unused branch of the exterior if)
if(#{fieldA}!=0,#{(fieldB}/if(#{fieldA}==0,1,#{fieldA})*100)+'%','')
But this added complexity makes me want to give up and use Javascript for this field.