这是维基百科的第二个例子SIGFPE 页面。
#include <limits.h>
int main(void)
{
volatile int x=INT_MIN;
volatile int y=-1;
x=x/y;
return 0;
}
它正在将 INT_MIN 的符号反转为正数。怎么可能是FPE?
最佳答案
维基百科文章回答:
... triggers the signal because the quotient, a positive number, is not representable.
INT_MIN / -1 = -INT_MIN
= INT_MAX + 1
=> invalid number
=> floating point exception (FPE)
关于c - 为什么会产生浮点异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7024026/