tags:

views:

314

answers:

2

I use an acceleration sensor to calculate the current accelerations and it returns the double value.

However I would like to compare the current acceleration with value 9.8. Before doing that i have to round the value received from the sensor so the question is: How to round a doble value to a selected number of decimals in .NET?

+3  A: 

Math.Round - i.e.

double val = Math.Round(current, 1); // 1dp
Marc Gravell
arghhh beat me by 50 seconds :-)
Nathan Koop
I edited, so you may well get the points anyway ;-p
Marc Gravell
+6  A: 

Math.Round(number, precision)

http://msdn.microsoft.com/en-us/library/zy06z30k.aspx

Nathan Koop