开发者

what does the compiler do on my method concerning type conversion

开发者 https://www.devze.com 2023-02-09 00:27 出处:网络
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 informatio

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

精彩评论

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

关注公众号