无法将类型'float'隐式转换为'int'

蜡笔

当我尝试运行以下代码时,出现错误“无法将类型'float'隐式转换为'int'”。

我已经进行了很多搜索,但不幸的是我无法找到任何有关此类错误的帮助。

int sum1, cols, rows;

float h, twoEnds, x;

sum1 = (h - ((cols) * x) + twoEnds)) / (cols + 1);
德米特里·拜琴科(Dmitry Bychenko)

错误清楚地说明了

无法将类型'float'隐式转换为'int'

所以,你有一个float不能结果implictly转换sum1它的类型的int尝试显式转换/广播

 sum1 = (int) ((h - ((cols) * x) + twoEnds)) / (cols + 1));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法将类型 'IEnumerable<int> 隐式转换为 'int'

无法将类型int []隐式转换为int?[]

无法将类型'bool'隐式转换为'float'

无法将类型'float'隐式转换为'void'

将float转换为int隐式vs显式(cast)差异

无法将类型'int'隐式转换为'bool'Unity

无法将类型'double'隐式转换为'int'。-错误

无法将类型“ double”隐式转换为“ int”

无法将类型“int”隐式转换为“bool”

无法将类型隐式转换为int []

无法将类型“bool”隐式转换为“int”

如果隐式转换为 int 类型,float 常量何时溢出

为什么在调用构造函数时将int隐式转换为float而不是double?

不能将类型 float 隐式转换为 int。存在显式转换(您是否缺少演员表?)

2错误-无法将类型system.collection.generic.list <float>隐式转换为float,也无法将float []类型隐式转换为float

隐式将NSNumber *转换为int

隐式将int转换为double

隐式将float转换为其他类型

无法将int隐式转换为int []

“无法将'float'对象转换为隐式str“

当似乎不涉及“ long”类型时,无法将“ long”类型隐式转换为“ int”

数组出现问题(无法将类型'int'隐式转换为'int []')

C# - 无法将类型“int”隐式转换为“int[][]” - CodeFights

使用 AddExplosionForce 时无法将类型“float”隐式转换为“UnityEngine.Vector3”

无法使用Math.Pow()将类型'double'隐式转换为'float'

TypeError:无法将“ int”对象隐式转换为str

TypeError:无法将“ int”对象隐式转换为str

TypeError:无法将int隐式转换为str

webservice无法构建-“无法将类型'string'隐式转换为'int'”