: 부호 없는 정수 = unsigned int
#include <limits> // 헤더파일 불러오면 각 자료형의 max, min값 사용 가능
// Create two unsigned integer of maximum and minimum values
unsigned int num1 = numeric_limits <unsigned int> :: max();
unsigned int num2 = numeric_limits <unsigned int> :: min();
// Print the maximum and minimum values
cout << "The value of maximum unsigned int:" << num1 << endl; // 4294967295
cout << "The value of minimum unsigned int:" << num2 << endl; // 0
// Force the integers to overflow
num1 += 1; // overflow 발생시키기
num2 −= 1; // underflow 발생시키기
// Print the overflowed values
cout << "The value of num1 + 1 after overflow:" << num1 << endl; // 0
cout << "The value of num1 - 1 after underflow:" << num2 << endl; // 4294967295
#include <limits> // 헤더파일 불러오면 각 자료형의 max, min값 사용 가능
// Find the maximum and minimum of an integer
int num1 = numeric_limits <int> :: max();
int num2 = numeric_limits <int> :: min();
// Print the maximum and minimum values
cout << "Value of maximum signed int:" << num1 << endl; // 2147483647
cout << "Value of minimum signed int:" << num2 << endl; // -2147483648
// Cause num1 and num2 to overflow
num1 += 1; // overflow 발생시키기
num2 −= 1; // underflow 발생시키기
// Print the overflowed values
cout << "The value of num1 + 1 after overflow:" << num1 << endl; // −2147483648
cout << "The value of num2 - 1 after underflow:" << num2 << endl; // 2147483647
#include <limits> // 헤더파일 불러오면 각 자료형의 max, min값 사용 가능
// Find the positive and negative maximum double
double num1 = +numeric_limits <double> :: max ();
double num2 = −numeric_limits <double> :: max ();
// Print the positive and negative maximum double
cout << "The value of maximum double:" << num1 << endl; // 1.79769e+308
cout << "The value of minimum double:" << num2 << endl; // -1.79769e+308
// Multiply the values by 1000.00
num1 *= 1000.00; // overflow 발생시키기
num2 *= 1000.00; // underflow 발생시키기
// Print the overflowed values
cout << "The value of num1 * 1000 after overflow:" << num1 << endl; // INF
cout << "The value of num2 * 1000 after underflow:" << num2 << endl; // −INF
INF
: Infinity 무한대를 의미 → overflow
발생 시 INF
, underflow
발생 시 -INF