开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜