검색결과 리스트
MIN에 해당되는 글 1건
- 2012.11.01 수치 타입의 최대 값과 최소 값
int, short, float 타입 등의 수치 타입의 최대 값과 최소 값을 알고 싶을 때는
STL에 있는 nurmeric_limit를 사용합니다.
너무 간단한 내용이니 아래의 예제 코드로 설명을 끝내겠습니다^^
#include <iostream>
#include <limits>
int main()
{
std::cout << "float 타입의 최대 값: " << std::numeric_limits<float>::max( ) << std::endl;
std::cout << "double 타입의 최대 값: " << std::numeric_limits<double>::max( ) << std::endl;
std::cout << "short 타입의 최대 값: " << std::numeric_limits<short>::max( ) << std::endl;
std::cout << "int 타입의 최대 값: " << std::numeric_limits<int>::max( ) << std::endl;
std::cout << "short 타입의 최대 값: " << std::numeric_limits<short>::max( ) << std::endl;
std::cout << "__int64 타입의 최대 값: " << std::numeric_limits<__int64>::max( ) << std::endl;
std::cout << "float 타입의 최소 값: " << std::numeric_limits<float>::min( ) << std::endl;
std::cout << "double 타입의 최소 값: " << std::numeric_limits<double>::min( ) << std::endl;
std::cout << "short 타입의 최소 값: " << std::numeric_limits<short>::min( ) << std::endl;
std::cout << "int 타입의 최소 값: " << std::numeric_limits<int>::min( ) << std::endl;
std::cout << "short 타입의 최소 값: " << std::numeric_limits<short>::min( ) << std::endl;
std::cout << "__int64 타입의 최소 값: " << std::numeric_limits<__int64>::min( ) << std::endl;
return 0;
}
< 결과 >
댓글