C18的数学计算问题
unsignedlong c;unsigned int a;
unsigned int b;
c=a*b;
算出来的结果C的高2个字节总是清零,也就是只有16位数。 正确的用法是c = a;c*=b;
unsigned long c;
unsigned int a,b;
c = a;
c *= b;(用c=a;c*=b;代替c= a*b)
或者...
unsigned long c;
unsigned int a,b;
c=(long)a*(long)b;
页:
[1]