为什么 SIGFPE 用于整数算术异常? [英] Why was SIGFPE used for integer arithmetic exceptions?

查看:56
本文介绍了为什么 SIGFPE 用于整数算术异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 SIGFPE 用于整数算术异常,例如被零除,而不是为整数算术异常创建单独的信号,或者通常首先为算术异常命名信号?>

Why was SIGFPE used for integer arithmetic exceptions, such as division by zero, instead of creating a separate signal for integer arithmetic exceptions or naming the signal in the first place for arithmetic exceptions generally?

推荐答案

IEEE Std 1003.1 标准将 SIGFPE 定义为:

IEEE Std 1003.1 Standard defines SIGFPE as:

错误的算术运算.

并没有真正提到浮点运算.这背后的推理没有明确说明,但这是我的看法.

And doesn't really mention floating point operations. Reasoning behind this is not clearly stated, but here's my take on it.

x86 FPU 可以使用 FIDIV 等指令同时对整数和浮点数据进行运算,因此不清楚将浮点数据除以整数零是否会生成浮点或和整数点异常.

x86 FPU can operate on both integer and floating point data at the same time with instructions such as FIDIV, thus it would be unclear whether dividing floating poitn data by integer zero would generate a floating or and integer point exception.

此外,高达 80486(与 ISO/ANSI C 标准同年发布)x86 CPU 根本没有浮点功能,浮点协处理器是一个单独的芯片.可以使用软件浮点仿真代替芯片,但使用 CPU 内置的 ALU(整数算术逻辑单元)会抛出整数异常.

Additionally, up to 80486 (which was released the same year as the ISO/ANSI C standard) x86 CPUs did not have floating point capabilities at all, floating point co-processor was a separate chip. Software floating point emulation could be used in place of the chip, but that used CPU's built in ALU (integer arithmetic-logical unit) which would throw integer exceptions.

这篇关于为什么 SIGFPE 用于整数算术异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆