【发布时间】:2016-07-14 10:47:43
【问题描述】:
下面显示的代码是从here获取的。但输出有些不同。
#include <iostream>
#include <limits>
using namespace std;
int main()
{
cout << "The quiet NaN for type float is: "
<< numeric_limits<float>::quiet_NaN()
<< endl;
cout << "The quiet NaN for type int is: "
<< numeric_limits<int>::quiet_NaN()
<< endl;
cout << "The quiet NaN for type long double is: "
<< numeric_limits<long double>::quiet_NaN()
<< endl;
}
这是我的 VS2015 中的打印输出:
The quiet Nan for type float is : nan
The quiet Nan for type int is : 0
The quiet Nan for type long double is : nan
虽然 MSDN 文章中的输出说,它应该是:
The quiet NaN for type float is: 1.#QNAN
The quiet NaN for type int is: 0
The quiet NaN for type long double is: 1.#QNAN
这与this blog entry上显示的表格中的值一致。
【问题讨论】:
-
微软过去常常使用 MSDN 引用中描述的那些时髦的东西。但是 C99 标准化了 NaN 值的输出应该是什么,这就是你的输出显示的内容,所以看起来微软终于赶上了 C 标准。
-
非常高兴您回答我的问题。谢谢。
-
MS doc 中是否有任何关于更改的参考文章?
-
此处记录了更改(使用 google 很难获得):msdn.microsoft.com/en-us/library/bb531344.aspx
-
msdn.microsoft.com/library/… 似乎已经过时,尽管提到它适用于 VS 2015 :(
标签: c++ visual-studio-2015 nan