例如:
unsigned char Result = 0;
unsigned char FristNum ;
unsigned cahr SecondNum;
Result = FristNum * SecondNum;
如果两个数相乘结果大于 255 需要将乘数与被乘数类型转换成 int型或者
long 型,即需要类型转换,修饰采用括号内类型的表达形式,例如: unsigned int Result = 0;
unsigned char FristNum ;
unsigned cahr SecondNum;
Result = (unsigned int)FristNum * (unsigned int)SecondNum;
|