6.6 数据类型转换
隐式类型转换
自动转换
算术、逻辑、赋值表达式中数据类型不同
函数形参与实参类型不匹配
函数返回值类型与函数类型不匹配
转换规则
低精度->高精度 有符号->无符号
signed->unsigned
char -> short -> int -> unsigned -> long -> double -> long double
char -> short ->int ->long ->long long ->float ->double ->…
强制类型转换
关注
char—int:值不变、存储格式发生变化
int—char:截断
signed—unsigned:值改变,存储格式不发生变化