float和unsigned short
情况一:
unsigned short a=98;
float b=6.25e+007;
a+=b;
cout<<a<<endl;
结果输出:44290
分析:a+=b;应该是将a转换为float然后再和b做加法,然后再从float转换回unsigned short
所以有2次类型转换.
情况二:
unsigned short a=98;
float b=6.25e+007;
b+=a;
cout<<(unsigned short)b<<endl;
结果输出:44288
分析:b+=a;也是把a转换为float,然后做加法,cout的时候也是把float转换回unsigned short
和情况一一样,做了2次类型转换但是结果为什么又不一样了?