프로그래밍/C++
C++ std::numeric_limits
comflex
2022. 2. 19. 10:09
728x90
반응형
std::numeric_limits
numeric_limits 클래스 탬플릿은 수치 타입의 다양한 속성을 표준화된 방법으로 질의하기 위한 방법을 제공한다.
목차
- min
- max
min
주어진 타입의 가장 작은 유한 값을 리턴한다.
max
주어진 타입의 가장 큰 유한 값을 리턴한다.
- 코드
#include <iostream>
using namespace std;
int main()
{
cout << "Type \t | min \t\t | max" << endl;
cout << "int \t |" << numeric_limits<int>::min() << "\t│ "
<< numeric_limits<int>::max() << endl;
cout << "double \t |" << numeric_limits<double>::min() << "\t│ "
<< numeric_limits<double>::max() << endl;
return 0;
}
- 출력
Type | min | max
int |-2147483648 │ 2147483647
double |2.22507e-308 │ 1.79769e+308728x90
반응형