what does the compiler do on my method concerning type conversion
Hey, I appreciate if you could tell me what the compiler does on my method. If I call it with Area(10.1,10.1);
it returns me 102
. So the .01
get cut? Do you have a good site where I can get information about this particular topic? thx for your time!
float Area (float length, float width){
int result;
result = length*width;
return res开发者_开发百科ult;
}
Since you're assigning the value of a float expression to an int, the data simply gets truncated upon assignment (but after the expression is evaluated).
精彩评论