본문 바로가기
WORK/Sotfware

C언어 자료형의 크기

by KANG Stroy 2012. 5. 4.
728x90
728x90

Microsoft Visual C++ recognizes the types shown in the table below.

Type NameBytesOther NamesRange of Values
int*signed, 
signed int
System dependent
unsigned int*unsignedSystem dependent
__int81
  0xFF
char, 
signed char
–128 to 127
__int162
  0xFF FF
short, 
short int, 
signed short int
–32,768 to 32,767
__int32

4
  0xFF FF FF

signed, 
signed int
–2,147,483,648 to 2,147,483,647
__int648
 0xFFFF FFFF
none–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
bool1nonefalse or true
char1signed char–128 to 127
unsigned char1none0 to 255
short2short int, 
signed short int
–32,768 to 32,767
unsigned short2unsigned short int0 to 65,535
long4long int, 
signed long int
–2,147,483,648 to 2,147,483,647
long long8none (but equivalent to __int64)–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned long4unsigned long int0 to 4,294,967,295
enum*noneSame as int
float4none3.4E +/- 38 (7 digits)
double8none1.7E +/- 308 (15 digits)
long doublesame as doublenonesame as double
wchar_t2__wchar_t0 to 65,535

A variable of __wchar_t designates a wide-character or multibyte character type. By default wchar_t is a typedef for unsigned short.

Sizes of Fundamental Types
TypeSize
bool1 byte
charunsigned charsigned char1 byte
shortunsigned short2 bytes
intunsigned int4 bytes
__intn1, 2, 4, or 8 bytes depending on the value of n. __intn is Microsoft-specific.
longunsigned long4 bytes
float4 bytes
double8 bytes
long double18 bytes
long longEquivalent to __int64.
1   The representation of long double and double is identical. However, long double and double are separate types.

Fundamental Types of the C++ Language
CategoryTypeContents
IntegralcharType char is an integral type that usually contains members of the execution character set — in Microsoft C++, this is ASCII.
  The C++ compiler treats variables of type charsigned char, andunsigned char as having different types. Variables of type char are promoted to int as if they are type signed char by default, unless the /J compilation option is used. In this case they are treated as typeunsigned char and are promoted to int without sign extension.
 boolType bool is an integral type that can have one of the two values trueor false. Its size is unspecified.
 shortType short int (or simply short) is an integral type that is larger than or equal to the size of type char, and shorter than or equal to the size of type int.
  Objects of type short can be declared as signed short or unsigned shortSigned short is a synonym for short.
 intType int is an integral type that is larger than or equal to the size of type short int, and shorter than or equal to the size of type long.
  Objects of type int can be declared as signed int or unsigned int.Signed int is a synonym for int.
 __intnSized integer, where n is the size, in bits, of the integer variable. The value of n can be 8, 16, 32, or 64. (__intn is a Microsoft-specific keyword.)
 longType long (or long int) is an integral type that is larger than or equal to the size of type int.
  Objects of type long can be declared as signed long or unsignedlongSigned long is a synonym for long.
FloatingfloatType float is the smallest floating type.
 doubleType double is a floating type that is larger than or equal to type float, but shorter than or equal to the size of type long double.1
 long double1Type long double is a floating type that is equal to type double.
Wide-character__wchar_tA variable of __wchar_t designates a wide-character or multibyte character type. By default, wchar_t is a typedef for unsigned short; see /Zc:wchar_t for more information.
Use the L prefix before a character or string constant to designate the wide-character-type constant.
1   The representation of long double and double is identical. However, long double and double are separate types.


728x90

댓글