当我在VS2015中处理代码时,我得到了不同的输出.有什么解释吗

I get different output when I process the code in VS2015. Is there any explanation?

本文关键字:输出 什么 解释 VS2015 处理 代码      更新时间:2023-10-16

下面显示的代码就是在这里获得的。但产出有些不同。

#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

这与该博客条目上显示的表中的值一致。

VS为这些特殊的IEEE浮点值使用的sentinel字符串的更改列在"Visual C++更改历史2003-2015"中的"无限和NaN格式"下https://msdn.microsoft.com/en-us/library/bb531344.aspx

然而,他们似乎错过了在一些VS2015文档中更新它,例如。https://msdn.microsoft.com/library/9e817177-0e91-48e6-b680-0531c4b26625.aspx;我已经提交了一份更正,让他们知道这不太正确。