安静的NaN和信号NaN有什么区别? [英] What is difference between quiet NaN and signaling NaN?
问题描述
在C ++编程中可以生成哪一个?作为程序员,我可以编写一个程序,导致一个sNaN吗?解决方案
当一个操作导致一个安静的NaN,没有指示任何异常,直到程序检查结果并看到一个NaN。也就是说,如果在软件中实现浮点,计算将继续进行,而没有来自浮点单元(FPU)或库的任何信号。信号NaN将产生一个信号,通常以FPU的例外形式。是否抛出异常取决于FPU的状态。
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屋!