Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

Show:
© 2017 Microsoft