M: In Google Docs, I'm trying to create a function that has the possibility of throwing a divide-by-zero problem. What's the name of a function that can handle that? So that if one of the divisors ends up being zero, it'll just give zero as the result.
G: TL;DR: Use
IFERROR() (or IF() with a
zero check).
In Google Sheets (the spreadsheet part of Google
Docs), division by zero throws a #DIV/0! error. The
standard way to neutralize that is:
=IFERROR(A1 / B1, 0)
If B1 is zero (or blank, or anything that errors), the
result is 0.
If you want to only guard against zero (not other errors):
=IF(B1 = 0, 0, A1 / B1)
IFERROR#DIV/0!,
#VALUE!, #N/A, etc.If blanks should behave differently:
=IF(B1 = "", 0, A1 / B1)
Name you were looking for:
IFERROR
That’s the canonical answer.