출처 : [msdn]
numeric_limits::infinity
Visual Studio 2005The representation of positive infinity for a type, if available.
The return value is meaningful only if has_infinity is true.
// numeric_limits_infinity.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float>::has_infinity <<endl;
cout << numeric_limits<double>::has_infinity<<endl;
cout << numeric_limits<long double>::has_infinity <<endl;
cout << numeric_limits<int>::has_infinity <<endl;
cout << numeric_limits<__int64>::has_infinity <<endl;
cout << "The representation of infinity for type float is: "
<< numeric_limits<float>::infinity( ) <<endl;
cout << "The representation of infinity for type double is: "
<< numeric_limits<double>::infinity( ) <<endl;
cout << "The representation of infinity for type long double is: "
<< numeric_limits<long double>::infinity( ) <<endl;
}
Output
1
1
1
0
0
The representation of infinity for type float is: 1.#INF
The representation of infinity for type double is: 1.#INF
The representation of infinity for type long double is: 1.#INF
Visual Studio 2005
The representation of positive infinity for a type, if available.
The return value is meaningful only if has_infinity is true.
// numeric_limits_infinity.cpp // compile with: /EHsc #include <iostream> #include <limits> using namespace std; int main( ) { cout << numeric_limits<float>::has_infinity <<endl; cout << numeric_limits<double>::has_infinity<<endl; cout << numeric_limits<long double>::has_infinity <<endl; cout << numeric_limits<int>::has_infinity <<endl; cout << numeric_limits<__int64>::has_infinity <<endl; cout << "The representation of infinity for type float is: " << numeric_limits<float>::infinity( ) <<endl; cout << "The representation of infinity for type double is: " << numeric_limits<double>::infinity( ) <<endl; cout << "The representation of infinity for type long double is: " << numeric_limits<long double>::infinity( ) <<endl; }
Output
1 1 1 0 0 The representation of infinity for type float is: 1.#INF The representation of infinity for type double is: 1.#INF The representation of infinity for type long double is: 1.#INF
반응형
'STLTemplate > STL & EffectiveSTL' 카테고리의 다른 글
string 대소문자 변환 (0) | 2012.11.01 |
---|---|
STL bitset 진수 변환 (0) | 2012.11.01 |
lower_bound,upper_bound 예제소스 (0) | 2012.11.01 |
반복자 어댑터(Iterator Adaptors) – inserter(), back_inserter(), front_inserter() (0) | 2012.11.01 |
iterator_traits( 반복자 특질 )이란 무엇인가? (0) | 2012.11.01 |