我 st倒了以下关于维基佩亚的例子(:http://en.wikipedia.org/wiki/Type_conversion#Implicit_type_conversion)。
#include <stdio.h>
int main()
{
int i_value = 16777217;
float f_value = 16777217.0;
printf("The integer is: %i
", i_value); // 16777217
printf("The float is: %f
", f_value); // 16777216.000000
printf("Their equality: %i
", i_value == f_value); // result is 0
}
他们的解释: “这种奇迹的起因是含蓄地投放i_数值,将其与f_数值相比较;这种投射法失去精确性,使数值被比较不同”。
Isn t this wrong? If i_value were cast to float, then both would have the same loss in precision and they would be equal. So i_value must be cast to double.