divide by zero - c programming

后端 未结 3 2049
春和景丽
春和景丽 2020-12-11 16:05

I have a question about the next code:

int main { 
double x = 0;
double y = 0/x;

if(y==1) {.....}
....
....
return 0;
}

When I run the cod

3条回答
  •  情话喂你
    2020-12-11 17:03

    The reason you don't get an exception or error is because for a double, infinity and NaN are defined (see IEEE floating point) but when you try the same for integer, you'll get an error because NaN/Infinity aren't defined

提交回复
热议问题