如何将Double舍入到VB .NET中最接近的整数?

时间:2008-12-18 15:50:27

标签: vb.net double rounding

如何将Double向下舍入到VB .NET中最接近的整数?

3 个答案:

答案 0 :(得分:20)

这已经很老了,但是使用Math.Truncate的已接受答案在技术上是不正确的:截断将向零舍入,而不是向下。例如,-1.5舍入为-1而不是-2。

为了始终围绕向下,请使用Math.Floor

答案 1 :(得分:8)

我们在谈论VB.NET还是VB6?在VB.NET中使用Math.Truncate

答案 2 :(得分:0)

d d为小数= 1.50

将我视作int64 = convert.toint64(D)

这是我们使用的逻辑