【发布时间】:2013-08-02 16:20:40
【问题描述】:
操作如下:
public float InfectionPercent()
{
return (infected + zombies) * 100 / population;
}
值是:
int infected = 20196093
int zombies = 1978138
int population = 32608521
返回值为-63
将 100 更改为 100f 可以解决此问题。
为什么该操作返回-63 而不是63?
【问题讨论】:
-
什么是感染者、僵尸、人口类型?短的?诠释?
-
@LoganMurphy 操作忘记了!他们都是
ints -
可能 .Net 足够聪明,可以理解周围没有僵尸
标签: c# floating-point int