错误评估变量C#

时间:2016-12-20 16:16:58

标签: c# unity3d

我正在使用Visual Studio 2015 C#和Unity。评估后cell.x的值是错误的。

PointCell cell = new PointCell();
cell.x = (int)((point.x - (discretization / 2f)) / discretization);
cell.y = (int)((point.y - (discretization / 2f)) / discretization);
return cell;

point.x = 4.32f and discretization = 0,32f

应评估为13,但评估为12。

请参阅print debug watches。

code 手表: watches

任何人都能解释一下吗?

编辑: PointCell代码:

public class PointCell
{
    public PointCell()
    {
        x = y = 0;
    }
    public PointCell(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public int x, y;
}

0 个答案:

没有答案