Hi Chris,
So here what the docs say
"Dividing a floating-point value by zero will result in either positive
infinity, negative infinity, or Not-a-Number (NaN) according to the rules of
IEEE 754 arithmetic. Floating-point operations never throw an exception. For
more information, see Single and Double."
-and-
"If a floating-point operation is invalid, the result of the operation is
NaN."
Why? You probably can find the answer in IEEE specs.
--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Chris" <ch********@pandora.be> wrote in message
news:uI***********************@phobos.telenet-ops.be...
Hi,
a strange behaviour when working with exceptions :
when I divide and integer by 0 will an exception be thrown. OK
but, when I divide a double by 0 is no exception thrown ???
How come ?
Try it out.
try
{
int i=1, j=0;
int result = i / j;
// double i=1.0, j=0;
// double result = i / j;
Console.WriteLine("Result {0} / {1} = {2}", i, j,result);
}
catch (Exception pExc)
{
Console.WriteLine("Exception caught : '{0}' ", pExc.Message);
}
can anybody explain this ?
thnx
Chris