CalculationWithDifferenceTpye
0赞
发表于 4/2/2013 10:55:18 AM
阅读(877)
//date :2013 4 2
//designer pengxiaoen
//function : calculation with difference type to known how the computer do with the difference type
#include "stdio.h"
int main()
{
unsigned int i;
int j;
char k;
int unsigned_with_int,unsigned_with_char,int_with_char;
i = 10;
j = -5;
k = 12;
unsigned_with_int = i + j;
unsigned_with_char = i + k;
int_with_char = j + k;
printf ("unsigned_with_int = %d\n",unsigned_with_int);
printf ("unsigned_with_char = %d\n",unsigned_with_char);
printf ("int_with_char = %d\n",int_with_char);
system ("pause");
}
最终的结果:
全部正确。这就是传说中的运算时的double 类型转换?!