2주 정도 전에 Programming 시험을 쳤다. 다행히 문제를 풀기는 했는데, Data Type들의 사이즈를 헷갈려서 printf 함수를 사용해서 가능 범위를 확인하고 문제를 풀 수 있었다. 그래서 간단하게 Data Type들의 출력 가능 범위를 짧게 정리해보았다.
Type | Storage Size | Value Range |
---|---|---|
char | 1 Byte | -128 ~ 127 or 0 ~ 255 |
unsigned char | 1 Byte | 0 ~ 255 |
signed char | 1 Byte | -128 ~ 127 |
int | 2 Bytes or 4 Bytes | -32,768 ~ 32,767 or -2,147,483,648 ~ 2,147,483,647 |
unsigned int | 2 Bytes or 4 Bytes | 0 ~ 65,535 or 0 ~ 4,294,967,295 |
short | 2 Bytes | -32,768 ~ 32,767 |
long | 4 Bytes | -2,147,483,648 ~ 2,147,483,647 |
unsigned long | 4 Bytes | 0 ~ 4,294,967,295 |
float | 4 Bytes | 1.2E-38 ~ 3.4E+38 (6 Decimal Places) |
double | 8 Bytes | 2.3E-308 ~ 1.7E+308 (15 Decimal Places) |
long double | 10 Bytes | 3.4E-4932 ~ 1.1E+4932 (19 Decimal Places) |
위 내용은 당연히 알아야 하는 정도의 기본인지도 모르겠다 (어쩌면 기본도 없이 Programming 시험을 보러 다녔는지도 모르겠다).
출처
- https://intellipaat.com/tutorial/c-tutorial/c-data-types/
- https://www.tutorialspoint.com/cprogramming/c_data_types.htm