如何将double的值除以int进行舍入?

时间:2017-07-29 14:01:20

标签: c#

我有这段代码:

Double secsSinceLastCheck = AS.pointsDate - DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
Int32 prt = AS.prt.Val();

var reducePoints = secsSinceLastCheck / prt;

我想要的是reducePoints是一个从等式右边的值向下舍入的整数。

1 个答案:

答案 0 :(得分:1)

试试这个

int reducePoints = Convert.ToInt32(Math.Floor(secsSinceLastCheck / Convert.ToDouble(prt)));