I ran the following snippet in the VS2015 C# interactive and got some very weird behavior.
> double divide(double a, double b)
. {
. try
. {
.
Why did the method return infinity while 3 / 0 threw an error and 3 / b threw a formated error?
Because in the first case the 0 is not an integer, is a double. While in the second is an integer. That you should realize here is that a double is a floating point number. So it doesn't have an exact value like an integer. On the other hand an integer can be represented by a computer with 100% accuracy.
Here you could find a very nice article regarding floating point numbers.