본문 바로가기
프로그래밍/C++

C++ std::numeric_limits

by comflex 2022. 2. 19.
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+308
728x90
반응형

'프로그래밍 > C++' 카테고리의 다른 글

C++ std::sort  (2) 2023.01.04
C++ enum 열거형  (1) 2023.01.04
C++ std::begin, std::end, iterator  (0) 2022.02.19
C++ std::tuple  (0) 2022.02.19
C++ std::pair  (0) 2022.02.19