[英]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);
如果我用
Area(10.1,10.1);
调用它Area(10.1,10.1);
it returns me 102
. 它给我
102
。 So the .01
get cut? 那么
.01
会被削减吗? 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 result;
}
由于将浮点表达式的值分配给int,因此分配时数据会被截断(但在计算表达式之后)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.