1、基本数据类型
数据类型 | 数据类型 | 字节 | 取值范围 |
char | 字符 | 1 | |
short | 短整型 | 2 | |
int | 整型 | 4 | |
long | 长整型 | 4 | |
long long | 更长的整型 | 8 | |
float | 单精度浮点数 | 4 | 链接 |
double | 双精度浮点数 | 8 | 链接 |
数据类型 取值范围
char -128 ~ +127
short -32768 ~ +32767
int -2147483648 ~ +2147483647
long -2147483648 ~ +2147483647
long long -9223372036854775808 ~ +9223372036854775807
float -340282346638528859811704183484516925440 ~
+340282346638528859811704183484516925440
double 太大了,不写了
2、float、double的精度
float 的精度为 6~7 位
double 的精度为 15~16 位
3、C语言编程环境中查看数据类型所占字节
int main()
{
//sizeof - 关键字 - 操作符 - 计算类型或者变量所占空间的大小
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
printf("%d\n", sizeof(long double));//8
return 0;
}