数据类型 | 名称 | 占用字节数 | 取值范围 |
---|---|---|---|
char(signed char) | 字符型(有符号字符型) | 1 | -128~127 |
unsigned char | 无符号字符型 | 1 | 0~255 |
short(signed short) | 短整型(有符号短整型) | 2 | -32768~32767 |
unsigned short | 无符号短整型 | 2 | 0~65535 |
int(signed) | 整型(有符号整型) | 4 | -2³¹~(2³¹-1) |
unsigned int | 无符号整型 | 4 | 0~(2³²-1) |
long int(signed long) | 长整型(有符号长整型) | 4 | -2³¹~(2³¹-1) |
unsigned long | 无符号长整型 | 4 | 0~(2³²-1) |
float | 单精度型 | 4 | -10³~10³ |
double | 双精度型 | 8 | -10³~10³ |
long double | 长双精度型 | 8 | -10³~10³ |
WORD(unsigned short) | 无符号短整型 | 2 | 0~65535 |
DWORD(unsigned long) | 无符号长整型 | 4 | 0~(2³²-1) |
BOOL(int) | 整型(有符号整型) | 4 | -2³¹~(2³¹-1) |
BYTE(unsigned char) | 无符号字符型 | 1 | 0~255 |
UINT(unsigned int) | 无符号整型 | 4 | 0~(2³²-1) |
WCHAR(wchar_t) | 16-bit UNICODE character | 2 | 0~65535 |
ULONG(unsigned long) | 无符号长整型 | 4 | 0~(2³²-1) |
HANDLE(void*)的指针 | 无符号整型 | 4 | 0~(2³²-1) |
HINSTANCE(void*)的指针 | 无符号整型 | 4 | 0~(2³²-1) |
HWND(void*)的指针 | 无符号整型 | 4 | 0~(2³²-1) |
HDC(void*)的指针 | 无符号整型 | 4 | 0~(2³²-1) |
十进制整数:除表示正负号外(“+”号可省略),以1~9开头的整数为十进制整数。
八进制整数:以0开头的整数为八进制整数。例如:0123,0367。
十六进制整数:以0X(0x)开头的数为十六进制整数。例如:0X123,0x1ABF。
长整型数与无符号整型数:以L或l结尾的整数为长整型数。例如:123L,0456l。
以U或u结尾的整数为无符号整型数。例如:23U,0456u,0X3BU。
以UL(或ul)或LU(或lu)结尾的整数为无符号长整型数。例如:24UL,0X95LU。
指数形式(又称浮点数、科学记数法)。它以10的多少次方表示,由数字、小数点、正负号、E(e)组成。例如:5E6,6.02e-3,-1.0e8,3.0e-4,分别表示5x10 6、6.02x10- 3、-1.0x10 8 、3.0x10- 4。
<span style="color: #ff0000;">注意:字母E(e)的前后必须要有数字,且E(e)后面的指数必须为整数。</span>