我正在使用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。
手表:
任何人都能解释一下吗?
编辑: 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;
}