Prevent possible division by 0, sign, and overflow errors.