I wrote a simple divide
function in C#:
private string divide(int a, int b)
{
return string.Format("Result: {0}", a / b);
}
Calling MessageBox.Show(divide(3, 0))
results in, as you would expect, a DivideByZeroException
.
So I decided to typecast a
into a float (to get a non-whole-number return value), like so:
private string divide(int a, int b)
{
return string.Format("Result: {0}", (float)a / b);
}
Oddly enough, this now shows me Result: Infinity.
This seems like a bug to me, although I could be mistaken. Is it because the result is now a float, and it's seen as essentially the return value of 3 / 1 x 10^-99999
or something similar?
I'm quite flabbergasted at this result.