什么是 1.#QNAN?

来源:百度知道 编辑:UC知道 时间:2024/05/21 20:41:38
在c++中出现的

此处的1.#QNAN是一个打印呈现,QNAN是指Quiet Not a Number,类似的浮点错误还有SNaN(Signaling Not a Number),通常如0.0/0.0、给负数开平方根等溢出或无效运算就会产生一个NAN结果的表示值,NaN及两种浮点错误的说明如下:
The value NaN (Not a Number) is used to represent a value that does not represent a real number. NaN’s are represented by a bit pattern with an exponent of all 1s and a non-zero fraction. There are two categories of NaN: QNaN (Quiet NaN) and SNaN (Signalling NaN).
A QNaN is a NaN with the most significant fraction bit set. QNaN’s propagate freely through most arithmetic operations. These values pop out of an operation when the result is not mathematically defined.
An SNaN is a NaN with the most significant fraction bit clear. It is used to signal an exception when used in operations. SNaN’s can be handy to assign to uninitialized variables to trap premature usage.
Semantically, QNaN’s denote indeterminate operations, while SNaN’s denote invalid operations. If a return value is a QNaN, it means that it is impossible to determi