我正在try 理解C中的隐式转换.我有以下C代码:
#include <stdio.h>
#include <stdlib.h>
int main() {
int a = -6 ;
size_t b = 100 ;
int result = a*b ; /* a is converted to size_t,
multiply two unsigned ints and cast the result to int
*/
double dresult = a*b ;
printf("Result : %d \n",result); // Output Result : -600
printf("Double Result : %f \n",dresult); // Output Double Result : 18446744073709551616.000000
return 0;
}
根据我对cppreference的理解,result
应该是一些垃圾值(转换为双精度值时打印),但为什么它给了我正确的值?