I have come across this problem in a calculation I do in my code, where the divisor is 0 if the divident is 0 too. In my code I return 0 for that case. I am wondering, while division by zero is generally undefined, why not make an exception for this case? My understanding why division by zero is undefined is basically that it cannot be reversed. However, I do not see this problem in the case 0/0.
EDIT OK, so this question spawned a lot of discussion. I made the mistake of over-eagerly accepting an answer based on the fact that it received a lot of votes. I now accepted AakashM’s answer, because it provides an idea on how to analyze the problem.
This is maths rather than programming, but briefly:
It’s in some sense justifiable to assign a ‘value’ of positive-infinity to
some-strictly-positive-quantity / 0, because the limit is well-definedHowever, the limit of
x / yasxandyboth tend to zero depends on the path they take. For example,lim (x -> 0) 2x / xis clearly 2, whereaslim (x -> 0) x / 5xis clearly 1/5. The mathematical definition of a limit requires that it is the same whatever path is followed to the limit.