Export (0) Print
Expand All
18 out of 32 rated this helpful - Rate this topic

Math.Round Method

Returns the number nearest the specified value.

Overload List

Returns the whole number nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Decimal) As Decimal
[C#] public static decimal Round(decimal);
[C++] public: static Decimal Round(Decimal);
[JScript] public static function Round(Decimal) : Decimal;

Returns the whole number nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Double) As Double
[C#] public static double Round(double);
[C++] public: static double Round(double);
[JScript] public static function Round(double) : double;

Returns the number with the specified precision nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Decimal, Integer) As Decimal
[C#] public static decimal Round(decimal, int);
[C++] public: static Decimal Round(Decimal, int);
[JScript] public static function Round(Decimal, int) : Decimal;

Returns the number with the specified precision nearest the specified value.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function Round(Double, Integer) As Double
[C#] public static double Round(double, int);
[C++] public: static double Round(double, int);
[JScript] public static function Round(double, int) : double;

Example

The following code example demonstrates rounding to nearest.

[Visual Basic] 
Math.Round(3.44, 1) 'Returns 3.4.
Math.Round(3.45, 1) 'Returns 3.4.
Math.Round(3.46, 1) 'Returns 3.5.

[C#] 
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

[C++] 

Math::Round(3.44, 1); //Returns 3.4.
Math::Round(3.45, 1); //Returns 3.4.
Math::Round(3.46, 1); //Returns 3.5.

[JScript] 
System.Math.Round(3.44, 1) //Returns 3.4.
System.Math.Round(3.45, 1) //Returns 3.4.
System.Math.Round(3.46, 1) //Returns 3.5.

See Also

Math Class | Math Members | System Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.