Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用加速度传感器来计算当前加速度并返回双精度值。
但是我想将当前加速度与值 9.8 进行比较。在此之前,我必须对从传感器接收到的值进行四舍五入,所以问题是:如何在 .NET 中将双精度值四舍五入为选定的小数位数?
Math.Round(数字,精度)
http://msdn.microsoft.com/en-us/library/zy06z30k.aspx
Math.Round - 即
double val = Math.Round(current, 1); // 1dp