(一)整型变量 整型变量分为4种:基本型(int)、短整型(short int 或short)、长整型(long int 或 long)和无符号型(unsigned int ,unsigned short,unsigned long)。 不同的编译系统对上述四种整型数据所占用的位数和数值范围有不同的规定。 类型说明符 说明: 单词signed来说明“有符号”(即有正负数之分),不写...
unsigned short b = 20u;// 简写成 unsigned short b = 20; unsigned long c = 30Lu; unsigned long long d = 40LLu; printf("unsigned int 型数据值:%u\n", a); printf("unsigned short 型数据值:%hu\n", b); printf("unsigned long 型数据值:%lu\n", c); pr...
1) short int(可简写为 short),和 int 一样,也是有符号整数 2) long int(简写:long),有符号整数 3) long long int(简写:long long),C99 标准添加的类型, 有符号整数 4) unsigned int(简写:unsigned),无符号整数,不能表示负数 5) unsigned long int(简写:unsigned long),无符号整数, 不能表示负数 6...
要打印unsigned int 数字,可以使用%u符号。打印long数值,可以使用%d 格式说明符。如果系统的 int 和 long 类型具有同样的长度,使用%d 就可以打印 long 数值,但是这会给程序移植到其他系统(这两种数据类型的长度不一样的系统)带来麻烦,所以建议使用 %ld 打印 long 数值。在x和o符号前也可以使用l前缀,因此 %lx表示...
char*(即指针变量): 4个字节(32位的寻址空间是2^32, 即32个bit,也就是4个字节。同理64位编译器) short int : 2个字节 int: 4个字节 unsigned int : 4个字节 float: 4个字节 double: 8个字节 long: 4个字节 long long: 8个字节 unsigned long: 4个字节...
long(长整型):用于存储长整数数据,根据不同的编译器和操作系统,一般占用四个或八个字节的空间。 signed(带符号类型):用于表示有正负号的整数,同时占用与 int 相同的空间。 unsigned(无符号类型):用于表示无符号整数,同时占用与 int 相同的空间。 1、u8:u8的数据范围为0~+127[0~2^8-1] ...
short int : 2个字节int: 4个字节unsigned int : 4个字节float: 4个字节double: 8个字节long: 4个字节long long: 8个字节unsigned long: 4个字节64位编译器char :1个字节char*(即指针变量): 8个字节short int : 2个字节int: 4个字节unsigned int : 4个字节float: 4个字节double: 8个字节long: 8...
C语言自动转换不同类型的行为称之为隐式类型转换 ,转换的基本原则是:低精度类型向高精度类型转换,具体是: int -> unsigned int -> long -> unsigned long -> long long -> unsigned long long -> float -> double -> long double 在执行算术运算时,计算机比C语言的限制更多。为了让计算机执行算术运算,通...
unsigned 是无符号的意思。 一、16位编译器 char :1个字节 char*(即指针变量): 2个字节 short int : 2个字节 int: 2个字节 unsigned int : 2个字节 float: 4个字节 double: 8个字节 long: 4个字节 long long: 8个字节 unsigned long: 4个字节 ...