Issue #22474:account for nulls and divide by zero