0

I'm writing a program that needs to compute the ratio of the difference between two numbers over the second number. i.e.,

(B-A)/A

I'm trying to figure out what's the best way to handle the case of 0 denominator. Practically, I could have a special case for A == 0 and set it to a very small number when that happens. However, how do I pick what number to use? Is there a generally accepted way of handling this?

Josh
  • 11
  • 3
    No, there's no general way to do this because it depends on what you're trying to do. What does A mean in your application? What do you want to happen when A=0? – Karl Feb 19 '22 at 03:27
  • Division by zero is not possible in this case. Output an error message. – Bumblebee Feb 19 '22 at 03:27

0 Answers0