2016-03-26 10 views
2

下記コードはhereです。しかし、出力は若干異なります。VS2015でコードを処理すると、出力が異なります。説明はありますか?

#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に示されている。

+0

マイクロソフトは、MSDNの見積もりに記載されている奇妙なことを使用していました。しかし、C99は出力が示すものであるNaN値の出力を標準化しています。したがって、マイクロソフトが最終的にC標準に追いついたように見えます。 –

+0

私の質問に答えてくれてありがとう。ありがとう。 – Mao

+0

MS docの変更点はありますか? – rents

答えて

0

これらの特別なIEEE浮動小数点値について、VSで使用されるセンチネル文字列の変化は、「歴史2003変更Visual C++は - 2015」の「無限大とNaNのフォーマット」の下に表示され、彼らは逃したように見えるしかしhttps://msdn.microsoft.com/en-us/library/bb531344.aspx

でいくつかのVS2015ドキュメントのアップデートhttps://msdn.microsoft.com/library/9e817177-0e91-48e6-b680-0531c4b26625.aspx;私はそれが正しくないと知らせるために訂正を提出しました。

関連する問題