Isn't a ternary here nicer?
return (foo == 0) ? 0 : bar / foo
or even return bar / max(1, foo)
in the case where foo is integer or tiny foo would overflow your range anyway