将FP除以0? [英] Catching FP division by 0?

查看:85
本文介绍了将FP除以0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数体系结构中,整数除以0会导致抛出

异常(有没有人知道行为不同的那个?)。我需要一个

方法来捕捉FP除以0.是否有标准方法可以这样做?

On most architectures integer division by 0 results in throwing an
exception (does anyone know of one that behaves differently?). I need a
way to catch FP division by 0. Is there a standard way to do so?

推荐答案

BigMan写道:
BigMan wrote:
在大多数架构中,整数除以0会导致抛出
异常


是吗?

(有没有人知道一个行为不同的人?)。


是的。在我的(Linux)上,它产生SIGFPE信号。我认为

大多数或所有Un * x系统都是如此。

我需要一种方法来捕捉FP除以0.是否有一种标准的方法可以做所以?
On most architectures integer division by 0 results in throwing an
exception
It does?
(does anyone know of one that behaves differently?).
Yes. On mine (Linux), it results in a signal SIGFPE. I think that''s true for
most or all Un*x systems.
I need a way to catch FP division by 0. Is there a standard way to do so?




编号唯一的标准方法是避免除以0.



No. The only standard way is to avoid division by 0.




" BigMan" <毕**** @ abv.bg>在消息中写道

news:11 ********************* @ l41g2000cwc.googlegro ups.com ...

"BigMan" <Bi****@abv.bg> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
在大多数架构中,整数除以0会导致抛出一个
异常(有人知道一个行为不同吗?)。我需要一种方法来捕捉FP除以0.是否有一种标准方法可以这样做?
On most architectures integer division by 0 results in throwing an
exception (does anyone know of one that behaves differently?). I need a
way to catch FP division by 0. Is there a standard way to do so?




AFAIK这取决于平台和编译器你使用。查看
http://www.fortran- 2000.com/ArnaudRe...ks.html#x86_FP


在Linux和Linux下为我工作cygwin。


HTH

Chris



AFAIK this depends on the platform and the compiler you use. Check out
http://www.fortran-2000.com/ArnaudRe...ks.html#x86_FP

which worked for me under Linux & cygwin.

HTH
Chris


检查除数是否不等于零。为什么你需要一个

异常来处理这个问题。如果需要,抛出自己的异常。这个

应该适用于所有系统。

Just check if the divisor is not equal to zero. Why do you need an
exception to handle this. Throw your own exception if need be. This
should work on all systems.


这篇关于将FP除以0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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