winnie 发表于 2009-4-18 15:18:39

C18的数学计算问题

unsignedlong c;
unsigned int a;
unsigned int b;
c=a*b;
算出来的结果C的高2个字节总是清零,也就是只有16位数。

winnie 发表于 2009-4-18 15:19:05

正确的用法是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]
查看完整版本: C18的数学计算问题