数据类型
char //字符数据类型
short // 短整形
int // 整形
long //长整形
long long //更长的整形
float //单精度浮点数
double //双精度浮点数
“a” 字符 a
int main()
{
char ch = ‘a’;char字符类型
int age = 18;int整型
short num=10;shor短整型
float weight = 55.5;单精度浮点型
double d =0.0;双精度浮点型
return 0;
}
每种类型的大小是多少?
printf(“%d\n”,sizeof(char)); 1 字节
printf(“%d\n”,sizeof(short)); 2 字节
printf(“%d\n”,sizeof(int)); 4 字节
printf(“%d\n”,sizeof(long)); 4 字节
printf(“%d\n”,sizeof(long long)); 8 字节
printf(“%d\n”,sizeof(float)); 4 字节
printf(“%d\n”,sizeof(double)); 8 字节
return 0;
计算机中的单位:
bit 比特位
byte 字节 = 8bit
kb 1024byte
mb 1024kb
gb 1024mb
tb 1024gb
pb 1024tb
计算机中识别二进制
1
0
8进制:0-7
10进制数字的组成:
0-9