Reinventing The Wheel

The Mathematics Behind the DivideByZeroException

As programmers, we have all heard of the DivideByZeroException. It is the exception that gets thrown in .NET when you try to divide an integer or decimal number by 0.
But what exactly is the mathematical reasoning for not being able to divide by zero?
To understand this, let's first look at what happens as you divide by numbers which are "close" to zero:

As you can see, the closer the denominator is to 0, the larger the number becomes. When the denominator is 0, the answer is theoretically equal to infinity which is not an exact value.
This is why the exception is thrown.
However, it is interesting to note that this exception only gets thrown for integer and decimal numbers. Dividing a floating-point value by zero results in positive infinity, negative infinity, or not a number (NaN) (see MSDN).