安静的NaN和信号NaN有什么区别? [英] What is difference between quiet NaN and signaling NaN?

查看:1893
本文介绍了安静的NaN和信号NaN有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过关于浮点数的内容,我知道NaN可能来自操作。但我完全不明白这些概念是什么。有什么区别?

在C ++编程中可以生成哪一个?作为程序员,我可以编写一个程序,导致一个sNaN吗?解决方案

当一个操作导致一个安静的NaN,没有指示任何异常,直到程序检查结果并看到一个NaN。也就是说,如果在软件中实现浮点,计算将继续进行,而没有来自浮点单元(FPU)或库的任何信号。信号NaN将产生一个信号,通常以FPU的例外形式。是否抛出异常取决于FPU的状态。



C ++ 11增加了一些语言控制浮点环境并提供创建和测试NaN的标准化方法。但是,这些控件是否被实现并不是很好的标准化,浮点异常通常不会像标准的C ++异常那样捕获。在POSIX / Unix系统中,浮动通常使用 SIGFPE 的处理程序捕获点异常。 p>

I have read about floating-point and I understand that NaN could results from operations. but I can't understand what are these concepts exactly. What is difference?

Which one can be produced during C++ programming? As a programmer, could I write a program cause a sNaN?

解决方案

When an operation results in a quiet NaN, there is no indication that anything is unusual until the program checks the result and sees a NaN. That is, computation continues without any signal from the floating point unit (FPU) or library if floating-point is implemented in software. A signalling NaN will produce a signal, usually in the form of exception from the FPU. Whether the exception is thrown depends on the state of the FPU.

C++11 adds a few language controls over the floating-point environment and provides standardized ways to create and test for NaNs. However, whether the controls are implemented is not well standardized and floating-point exceptions are not typically caught the same way as standard C++ exceptions.

In POSIX/Unix systems, floating point exceptions are typically caught using a handler for SIGFPE.

这篇关于安静的NaN和信号NaN有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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